From 13dff9d04ebbaa00d6b8f8cb45129fb7115481f7 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Fri, 25 Jun 2021 14:36:53 +0300 Subject: [PATCH 1/6] Added proxy to webpack dev server config --- cvat-ui/package.json | 2 +- cvat-ui/src/cvat-core-wrapper.ts | 5 ++--- cvat-ui/webpack.config.js | 11 +++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 9d50d3eaee21..9c32989844a0 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -5,7 +5,7 @@ "main": "src/index.tsx", "scripts": { "build": "webpack --config ./webpack.config.js", - "start": "REACT_APP_API_URL=http://localhost:7000 webpack-dev-server --config ./webpack.config.js --mode=development", + "start": "webpack-dev-server --env.API_URL=http://localhost:7000 --config ./webpack.config.js --mode=development", "type-check": "tsc --noEmit", "type-check:watch": "npm run type-check -- --watch", "lint": "eslint './src/**/*.{ts,tsx}'", diff --git a/cvat-ui/src/cvat-core-wrapper.ts b/cvat-ui/src/cvat-core-wrapper.ts index 66bbb3ac2c99..8ab8526c05a1 100644 --- a/cvat-ui/src/cvat-core-wrapper.ts +++ b/cvat-ui/src/cvat-core-wrapper.ts @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2021 Intel Corporation // // SPDX-License-Identifier: MIT @@ -6,8 +6,7 @@ import _cvat from 'cvat-core/src/api'; const cvat: any = _cvat; -cvat.config.backendAPI = - typeof process.env.REACT_APP_API_URL === 'undefined' ? '/api/v1' : `${process.env.REACT_APP_API_URL}/api/v1`; +cvat.config.backendAPI = '/api/v1'; export default function getCore(): any { return cvat; diff --git a/cvat-ui/webpack.config.js b/cvat-ui/webpack.config.js index 50c13cfee39f..2a71e576b8fb 100644 --- a/cvat-ui/webpack.config.js +++ b/cvat-ui/webpack.config.js @@ -12,7 +12,7 @@ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); const Dotenv = require('dotenv-webpack'); const CopyPlugin = require('copy-webpack-plugin'); -module.exports = { +module.exports = (env) => ({ target: 'web', mode: 'production', devtool: 'source-map', @@ -29,6 +29,13 @@ module.exports = { compress: false, inline: true, port: 3000, + proxy: { + '/api': { + target: env.API_URL, + secure: false, + changeOrigin: true, + }, + }, historyApiFallback: true, }, resolve: { @@ -134,4 +141,4 @@ module.exports = { ]), ], node: { fs: 'empty' }, -}; +}); From f7a61cbb7a22c8835d1a3cc5a668be1639becc34 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Fri, 25 Jun 2021 14:44:10 +0300 Subject: [PATCH 2/6] Added CHANGELOG increased package version --- CHANGELOG.md | 1 + cvat-ui/package-lock.json | 2 +- cvat-ui/package.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dfb735f3ac9..c512e0afb67e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated manifest format, added meta with related images () - Update of COCO format documentation () +- Updated Webpack Dev Server config to add proxxy () ### Deprecated diff --git a/cvat-ui/package-lock.json b/cvat-ui/package-lock.json index 88aa60b9a5a8..d44f9d4b2c6c 100644 --- a/cvat-ui/package-lock.json +++ b/cvat-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.20.5", + "version": "1.20.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 9c32989844a0..2085caf63d82 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.20.5", + "version": "1.20.6", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { From faf4cfcfc9eaf520ee8388722d7749fc1c716304 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Mon, 28 Jun 2021 10:46:53 +0300 Subject: [PATCH 3/6] Added webpack.config to eslintignore --- cvat-ui/webpack.config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cvat-ui/webpack.config.js b/cvat-ui/webpack.config.js index 2a71e576b8fb..82b20c252cfa 100644 --- a/cvat-ui/webpack.config.js +++ b/cvat-ui/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT @@ -29,14 +29,14 @@ module.exports = (env) => ({ compress: false, inline: true, port: 3000, + historyApiFallback: true, proxy: { '/api': { - target: env.API_URL, + target: env && env.API_URL, secure: false, changeOrigin: true, }, }, - historyApiFallback: true, }, resolve: { extensions: ['.tsx', '.ts', '.jsx', '.js', '.json'], From e251607cbd1a3f4245c9ec732fddcae471a18395 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Mon, 28 Jun 2021 11:17:27 +0300 Subject: [PATCH 4/6] Added webpack.config to eslintignore --- .eslintignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintignore b/.eslintignore index 54f42aa52ac2..a78a1bfc9b78 100644 --- a/.eslintignore +++ b/.eslintignore @@ -8,3 +8,4 @@ keys/ logs/ static/ templates/ +cvat-ui/webpack.config.js \ No newline at end of file From 5e46f85e12b3a075c06cf92f5c92e50991c6719d Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Mon, 28 Jun 2021 11:32:46 +0300 Subject: [PATCH 5/6] Changed ignore to wildcard --- .eslintignore | 2 +- cvat-ui/src/cvat-core-wrapper.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintignore b/.eslintignore index a78a1bfc9b78..633911264896 100644 --- a/.eslintignore +++ b/.eslintignore @@ -8,4 +8,4 @@ keys/ logs/ static/ templates/ -cvat-ui/webpack.config.js \ No newline at end of file +*/webpack.config.js \ No newline at end of file diff --git a/cvat-ui/src/cvat-core-wrapper.ts b/cvat-ui/src/cvat-core-wrapper.ts index 8ab8526c05a1..f62cde272b5f 100644 --- a/cvat-ui/src/cvat-core-wrapper.ts +++ b/cvat-ui/src/cvat-core-wrapper.ts @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Intel Corporation +// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT From fb067bbe823a73ed015d0346b2a715b88af2bc10 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Tue, 29 Jun 2021 10:55:07 +0300 Subject: [PATCH 6/6] Changed path checker to regexp --- cvat-core/src/config.js | 4 ++-- cvat-ui/webpack.config.js | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cvat-core/src/config.js b/cvat-core/src/config.js index 93d9577936c4..3dcddc2b2a66 100644 --- a/cvat-core/src/config.js +++ b/cvat-core/src/config.js @@ -1,8 +1,8 @@ -// Copyright (C) 2019-2020 Intel Corporation +// Copyright (C) 2019-2021 Intel Corporation // // SPDX-License-Identifier: MIT module.exports = { - backendAPI: 'http://localhost:7000/api/v1', + backendAPI: '/api/v1', proxy: false, }; diff --git a/cvat-ui/webpack.config.js b/cvat-ui/webpack.config.js index 82b20c252cfa..f99c03cb91da 100644 --- a/cvat-ui/webpack.config.js +++ b/cvat-ui/webpack.config.js @@ -30,13 +30,17 @@ module.exports = (env) => ({ inline: true, port: 3000, historyApiFallback: true, - proxy: { - '/api': { + proxy: [ + { + context: (param) => + param.match( + /\/api\/.*|git\/.*|opencv\/.*|analytics\/.*|static\/.*|admin(?:\/(.*))?.*|documentation\/.*|django-rq(?:\/(.*))?/gm, + ), target: env && env.API_URL, secure: false, changeOrigin: true, }, - }, + ], }, resolve: { extensions: ['.tsx', '.ts', '.jsx', '.js', '.json'],