Skip to content

very slowly adding lang code stuff in #372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG-FRONTIER.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 8.8.0

- Removed some proxies that are no longer needed, and scoped some others tighter to not conflict with localhost URLs
- Update proxy tool with a pathFilter that looks for lang code in url

## 8.7.11

- 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.
Expand Down
30 changes: 14 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fs/react-scripts",
"version": "8.7.11",
"version": "8.8.0",
"upstreamVersion": "5.0.1",
"description": "Configuration and scripts for Create React App.",
"repository": {
Expand Down Expand Up @@ -82,7 +82,7 @@
"file-loader": "^6.2.0",
"fs-extra": "^10.0.0",
"html-webpack-plugin": "^5.5.0",
"http-proxy-middleware": "^1.0.5",
"http-proxy-middleware": "^3.0.2",
"identity-obj-proxy": "^3.0.0",
"intersection-observer": "^0.12.0",
"jest": "^27.4.3",
Expand Down
13 changes: 8 additions & 5 deletions packages/react-scripts/proxy/proxies.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ const proxies = [
accept:
'application/' /* 'application/x-gedcomx-v1+json', 'application/json', etc. */,
},
{
route: '/ask',
},
{
route: '/cis-web',
},
{
route: '/cmsa',
route: '/cmsa/api',
},
{
route: '/dz',
},
{
route: '/frontier',
route: '/frontier/beacon',
},
{
route: '/frontier/ip',
},
{
route: '/frontier/graphql',
},
{
route: '/hf',
Expand Down
10 changes: 6 additions & 4 deletions packages/react-scripts/proxy/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const { createProxyMiddleware } = require('http-proxy-middleware')
require('dotenv').config()

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

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

const langRegex = '^\/[a-z]{2,3}(-[a-zA-Z0-9-]*)?' // Copied from DTM haproxy config MATCH_root_lang_path_with_slash acl

// set default env target
// prod auth keys don't exist in fs-config for security reasons, so only other alt-envs for now
const target = process.env.BASE_URL

const setProxy = proxyConfig => {
const langPathRegex = new RegExp(langRegex + proxyConfig.route)
const options = {
target,
pathFilter: (pathname) => pathname.startsWith(proxyConfig.route) || pathname.match(langPathRegex),
changeOrigin: true,
logLevel: 'debug',
timeout: 5000,
Expand All @@ -46,15 +48,15 @@ const setProxies = (app, customProxies = []) => {
// (e.g., type 'application/' works for 'application/x-gedcomx-v1+json' and 'application/json')
if (req.headers.accept && req.headers.accept.indexOf(proxyConfig.accept) === 0) {
// set up proxy middleware and use immediately
createProxyMiddleware(proxyConfig.route, options)(req, res, next)
createProxyMiddleware(options)(req, res, next)
} else {
// wrong accept type: don't proxy request
next();
}
})
}
else {
app.use(createProxyMiddleware(proxyConfig.route, options))
app.use(createProxyMiddleware(options))
}
}

Expand Down