-
Notifications
You must be signed in to change notification settings - Fork 216
MPP-4282: (bugfix) Removed Hardcoded Domain in PROD #5730
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
Conversation
15d04ff
to
b9764a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On this branch, I ran:
npm run build
...
ag mock.com
And it still found this occurence of mock.com
in the out/_next/static/chunks/14603.1ff5bc9cb9342e89.js
output file.
... t.push(r.L.post("https://basket-mock.com/news/subscribe/" ...
Looking at the out/_next/static/chunks/14603.1ff5bc9cb9342e89.js.map
file, it looks like this comes from:
handlers.push(
http.post("https://basket-mock.com/news/subscribe/", (_info) => {
in the src/apiMocks/handlers.ts
file.
What I don't understand is: why is the apiMocks
directory included in our built JS file in the first place? It shouldn't need to be there right?
It seems like the full fix here is to figure out why the mock files are included in the JS build file at all?
Somewhere in the codebase, a file statically imports Webpack (and Next.js) includes everything reachable via static import in the bundle — regardless of runtime conditions. So even if mock logic is gated behind
…the entire file is bundled. let me check every place this is imported and make that fix. great callout! |
1b93d24
to
2c57ecc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay it's coming along. And we might be able to merge this as-is.
But, I'd still like to try to make sure no mocks are leaking into the production build. And now that we've changed the mock hosts to localhost
, I did a search for localhost
and found there are still 5 .js
files in the out/
directory with localhost
in them ...
npm run build
...
ag -l localhost out/
out/_next/static/chunks/8e9ea143.0567fc3a1c6cd547.js.map
out/_next/static/chunks/16659.5b061ed07f8b8f85.js
out/_next/static/chunks/14603.e5179c17c3c04895.js
out/_next/static/chunks/14596.abac252af574c9d1.js.map
out/_next/static/chunks/14603.e5179c17c3c04895.js.map
out/_next/static/chunks/14596.abac252af574c9d1.js
out/_next/static/chunks/pages/tracker-report-01173556999ea1fe.js.map
out/_next/static/chunks/16659.5b061ed07f8b8f85.js.map
out/_next/static/chunks/polyfills-42372ed130431b0a.js
out/_next/static/chunks/8e9ea143.0567fc3a1c6cd547.js
2c57ecc
to
3ff7ce2
Compare
3ff7ce2
to
d2bda49
Compare
frontend/src/apiMocks/mockData.ts
Outdated
price: 1.99, | ||
currency: "EUR", | ||
url: "https://payments-next.stage.fxa.nonprod.webservices.mozgcp.net/relay-premium-127/yearly/landing", | ||
let mockedRuntimeData: RuntimeData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question (non-blocking): So does moving this from export const
into if (process.env.NEXT_PUBLIC_MOCK_API === "true")
help prevent it from being automatically exported?
frontend/src/apiMocks/handlers.ts
Outdated
// necessary to prevent mocks leaking into prod | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (non-blocking): move this docstring up to the top of this if
block?
d2bda49
to
76ddecf
Compare
76ddecf
to
2ff879e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes the problematic hard-coded domains. Can you file a follow-up ticket to finish the work to prevent the mock & testing code from getting into the production build files?
This PR fixes MPP-4282
How to test:
/frontend/src/styles/colors.scss
).