Skip to content

Commit b91433b

Browse files
authored
Merge pull request #372 from fs-webdev/joeyTest
very slowly adding lang code stuff in
2 parents ffaab44 + 0e4491f commit b91433b

File tree

5 files changed

+35
-27
lines changed

5 files changed

+35
-27
lines changed

CHANGELOG-FRONTIER.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 8.8.0
2+
3+
- Removed some proxies that are no longer needed, and scoped some others tighter to not conflict with localhost URLs
4+
- Update proxy tool with a pathFilter that looks for lang code in url
5+
16
## 8.7.11
27

38
- Feature detection for private class fields was erroring out before running the check, now it will be within `eval` so it will run even if the browser doesn't support it.

package-lock.json

Lines changed: 14 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-scripts/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fs/react-scripts",
3-
"version": "8.7.11",
3+
"version": "8.8.0",
44
"upstreamVersion": "5.0.1",
55
"description": "Configuration and scripts for Create React App.",
66
"repository": {
@@ -82,7 +82,7 @@
8282
"file-loader": "^6.2.0",
8383
"fs-extra": "^10.0.0",
8484
"html-webpack-plugin": "^5.5.0",
85-
"http-proxy-middleware": "^1.0.5",
85+
"http-proxy-middleware": "^3.0.2",
8686
"identity-obj-proxy": "^3.0.0",
8787
"intersection-observer": "^0.12.0",
8888
"jest": "^27.4.3",

packages/react-scripts/proxy/proxies.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,23 @@ const proxies = [
1919
accept:
2020
'application/' /* 'application/x-gedcomx-v1+json', 'application/json', etc. */,
2121
},
22-
{
23-
route: '/ask',
24-
},
2522
{
2623
route: '/cis-web',
2724
},
2825
{
29-
route: '/cmsa',
26+
route: '/cmsa/api',
3027
},
3128
{
3229
route: '/dz',
3330
},
3431
{
35-
route: '/frontier',
32+
route: '/frontier/beacon',
33+
},
34+
{
35+
route: '/frontier/ip',
36+
},
37+
{
38+
route: '/frontier/graphql',
3639
},
3740
{
3841
route: '/hf',

packages/react-scripts/proxy/setupProxy.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ const { createProxyMiddleware } = require('http-proxy-middleware')
44
require('dotenv').config()
55

66
const setProxies = (app, customProxies = []) => {
7-
// detect env
8-
const env = process.env.TARGET_ENV || 'local'
97

108
// bring in auth middleware once required keys are set
119
const cookieParser = require('cookie-parser')
@@ -26,13 +24,17 @@ const setProxies = (app, customProxies = []) => {
2624
auth('/auth', app)
2725
console.log('\n/auth local proxy set up!')
2826

27+
const langRegex = '^\/[a-z]{2,3}(-[a-zA-Z0-9-]*)?' // Copied from DTM haproxy config MATCH_root_lang_path_with_slash acl
28+
2929
// set default env target
3030
// prod auth keys don't exist in fs-config for security reasons, so only other alt-envs for now
3131
const target = process.env.BASE_URL
3232

3333
const setProxy = proxyConfig => {
34+
const langPathRegex = new RegExp(langRegex + proxyConfig.route)
3435
const options = {
3536
target,
37+
pathFilter: (pathname) => pathname.startsWith(proxyConfig.route) || pathname.match(langPathRegex),
3638
changeOrigin: true,
3739
logLevel: 'debug',
3840
timeout: 5000,
@@ -46,15 +48,15 @@ const setProxies = (app, customProxies = []) => {
4648
// (e.g., type 'application/' works for 'application/x-gedcomx-v1+json' and 'application/json')
4749
if (req.headers.accept && req.headers.accept.indexOf(proxyConfig.accept) === 0) {
4850
// set up proxy middleware and use immediately
49-
createProxyMiddleware(proxyConfig.route, options)(req, res, next)
51+
createProxyMiddleware(options)(req, res, next)
5052
} else {
5153
// wrong accept type: don't proxy request
5254
next();
5355
}
5456
})
5557
}
5658
else {
57-
app.use(createProxyMiddleware(proxyConfig.route, options))
59+
app.use(createProxyMiddleware(options))
5860
}
5961
}
6062

0 commit comments

Comments
 (0)