Skip to content

Commit 961bc58

Browse files
authoredJun 29, 2021
Webpack dev server proxy (cvat-ai#3368)
* Added proxy to webpack dev server config * Added CHANGELOG increased package version * Added webpack.config to eslintignore * Added webpack.config to eslintignore * Changed ignore to wildcard * Changed path checker to regexp
1 parent c8b0521 commit 961bc58

File tree

7 files changed

+23
-11
lines changed

7 files changed

+23
-11
lines changed
 

‎.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ keys/
88
logs/
99
static/
1010
templates/
11+
*/webpack.config.js

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
- Updated manifest format, added meta with related images (<https://github.com/openvinotoolkit/cvat/pull/3122>)
2020
- Update of COCO format documentation (<https://github.com/openvinotoolkit/cvat/pull/3197>)
21+
- Updated Webpack Dev Server config to add proxxy (<https://github.com/openvinotoolkit/cvat/pull/3368>)
2122

2223
### Deprecated
2324

‎cvat-core/src/config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// Copyright (C) 2019-2020 Intel Corporation
1+
// Copyright (C) 2019-2021 Intel Corporation
22
//
33
// SPDX-License-Identifier: MIT
44

55
module.exports = {
6-
backendAPI: 'http://localhost:7000/api/v1',
6+
backendAPI: '/api/v1',
77
proxy: false,
88
};

‎cvat-ui/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cvat-ui/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "cvat-ui",
3-
"version": "1.20.5",
3+
"version": "1.20.6",
44
"description": "CVAT single-page application",
55
"main": "src/index.tsx",
66
"scripts": {
77
"build": "webpack --config ./webpack.config.js",
8-
"start": "REACT_APP_API_URL=http://localhost:7000 webpack-dev-server --config ./webpack.config.js --mode=development",
8+
"start": "webpack-dev-server --env.API_URL=http://localhost:7000 --config ./webpack.config.js --mode=development",
99
"type-check": "tsc --noEmit",
1010
"type-check:watch": "npm run type-check -- --watch",
1111
"lint": "eslint './src/**/*.{ts,tsx}'",

‎cvat-ui/src/cvat-core-wrapper.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// Copyright (C) 2020 Intel Corporation
1+
// Copyright (C) 2020-2021 Intel Corporation
22
//
33
// SPDX-License-Identifier: MIT
44

55
import _cvat from 'cvat-core/src/api';
66

77
const cvat: any = _cvat;
88

9-
cvat.config.backendAPI =
10-
typeof process.env.REACT_APP_API_URL === 'undefined' ? '/api/v1' : `${process.env.REACT_APP_API_URL}/api/v1`;
9+
cvat.config.backendAPI = '/api/v1';
1110

1211
export default function getCore(): any {
1312
return cvat;

‎cvat-ui/webpack.config.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2020 Intel Corporation
1+
// Copyright (C) 2020-2021 Intel Corporation
22
//
33
// SPDX-License-Identifier: MIT
44

@@ -12,7 +12,7 @@ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
1212
const Dotenv = require('dotenv-webpack');
1313
const CopyPlugin = require('copy-webpack-plugin');
1414

15-
module.exports = {
15+
module.exports = (env) => ({
1616
target: 'web',
1717
mode: 'production',
1818
devtool: 'source-map',
@@ -30,6 +30,17 @@ module.exports = {
3030
inline: true,
3131
port: 3000,
3232
historyApiFallback: true,
33+
proxy: [
34+
{
35+
context: (param) =>
36+
param.match(
37+
/\/api\/.*|git\/.*|opencv\/.*|analytics\/.*|static\/.*|admin(?:\/(.*))?.*|documentation\/.*|django-rq(?:\/(.*))?/gm,
38+
),
39+
target: env && env.API_URL,
40+
secure: false,
41+
changeOrigin: true,
42+
},
43+
],
3344
},
3445
resolve: {
3546
extensions: ['.tsx', '.ts', '.jsx', '.js', '.json'],
@@ -134,4 +145,4 @@ module.exports = {
134145
]),
135146
],
136147
node: { fs: 'empty' },
137-
};
148+
});

0 commit comments

Comments
 (0)
Please sign in to comment.