Skip to content

Commit

Permalink
Add proper development proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Billing committed Oct 1, 2020
1 parent 14391ab commit c966ecd
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
3 changes: 2 additions & 1 deletion tnoodle-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.0.4",
"@testing-library/user-event": "^12.1.4",
"coveralls": "^3.1.0"
"coveralls": "^3.1.0",
"http-proxy-middleware": "^1.0.5"
},
"jest": {
"collectCoverageFrom": [
Expand Down
4 changes: 1 addition & 3 deletions tnoodle-ui/src/main/api/tnoodle.api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
let backendUrl = new URL(window.location.origin);
backendUrl.port = 2014;

export const tNoodleBackend = backendUrl.toString();
export const tNoodleBackend = backendUrl.toString().replace(/\/$/g, '');

let zipEndpoint = "/wcif/zip";
let versionEndpoint = "/version";
Expand Down
2 changes: 1 addition & 1 deletion tnoodle-ui/src/main/api/tnoodle.socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class ScrambleClient {
let wsTNoodleBackend = new URL(tNoodleBackend);
wsTNoodleBackend.protocol = "ws:";

const BASE_URL = wsTNoodleBackend.toString();
const BASE_URL = wsTNoodleBackend.toString().replace(/\/$/g, '');

const SCRAMBLING_STATES = {
IDLE: "IDLE",
Expand Down
14 changes: 14 additions & 0 deletions tnoodle-ui/src/setupProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function(app) {
app.use(
['/frontend', '/version', '/wcif'],
createProxyMiddleware({
target: 'http://localhost:2014',
secure: false,
changeOrigin: true,
ws: true,
xfwd: true,
})
);
};
32 changes: 29 additions & 3 deletions tnoodle-ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,13 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/http-proxy@^1.17.4":
version "1.17.4"
resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.4.tgz#e7c92e3dbe3e13aa799440ff42e6d3a17a9d045b"
integrity sha512-IrSHl2u6AWXduUaDLqYpt45tLVCtYv7o4Z0s1KghBCDgIIS9oW5K1H8mZG/A2CfeLdEa7rTd1ACOiHBc1EMT2Q==
dependencies:
"@types/node" "*"

"@types/invariant@^2.2.33":
version "2.2.34"
resolved "https://registry.yarnpkg.com/@types/invariant/-/invariant-2.2.34.tgz#05e4f79f465c2007884374d4795452f995720bbe"
Expand Down Expand Up @@ -2630,7 +2637,7 @@ braces@^2.3.1, braces@^2.3.2:
split-string "^3.0.2"
to-regex "^3.0.1"

braces@~3.0.2:
braces@^3.0.1, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
Expand Down Expand Up @@ -5477,7 +5484,18 @@ http-proxy-middleware@0.19.1:
lodash "^4.17.11"
micromatch "^3.1.10"

http-proxy@^1.17.0:
http-proxy-middleware@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-1.0.5.tgz#4c6e25d95a411e3d750bc79ccf66290675176dc2"
integrity sha512-CKzML7u4RdGob8wuKI//H8Ein6wNTEQR7yjVEzPbhBLGdOfkfvgTnp2HLnniKBDP9QW4eG10/724iTWLBeER3g==
dependencies:
"@types/http-proxy" "^1.17.4"
http-proxy "^1.18.1"
is-glob "^4.0.1"
lodash "^4.17.19"
micromatch "^4.0.2"

http-proxy@^1.17.0, http-proxy@^1.18.1:
version "1.18.1"
resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549"
integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==
Expand Down Expand Up @@ -7130,6 +7148,14 @@ micromatch@^3.1.10, micromatch@^3.1.4:
snapdragon "^0.8.1"
to-regex "^3.0.2"

micromatch@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==
dependencies:
braces "^3.0.1"
picomatch "^2.0.5"

miller-rabin@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d"
Expand Down Expand Up @@ -8057,7 +8083,7 @@ performance-now@^2.1.0:
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=

picomatch@^2.0.4, picomatch@^2.2.1:
picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1:
version "2.2.2"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
Expand Down

0 comments on commit c966ecd

Please sign in to comment.