diff --git a/.eslintignore b/.eslintignore index 54f42aa5..63391126 100644 --- a/.eslintignore +++ b/.eslintignore @@ -8,3 +8,4 @@ keys/ logs/ static/ templates/ +*/webpack.config.js \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dfb735f..c512e0af 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-core/src/config.js b/cvat-core/src/config.js index 93d95779..3dcddc2b 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/package-lock.json b/cvat-ui/package-lock.json index f2847873..8df2dcbb 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 521a70e5..12d141fd 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,11 +1,11 @@ { "name": "cvat-ui", - "version": "1.20.5", + "version": "1.20.6", "description": "CVAT single-page application", "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 66bbb3ac..f62cde27 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) 2020-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 50c13cfe..f99c03cb 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 @@ -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', @@ -30,6 +30,17 @@ module.exports = { inline: true, port: 3000, historyApiFallback: true, + 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'], @@ -134,4 +145,4 @@ module.exports = { ]), ], node: { fs: 'empty' }, -}; +});