Limit Webpack dev server allowed CORS origins#11866
Merged
Conversation
aduth
commented
Feb 11, 2025
| web: WEBPACK_PORT=${WEBPACK_PORT:-3035} bundle exec rackup config.ru --port ${PORT:-3000} --host ${FOREMAN_HOST:-${HOST:-localhost}} | ||
| worker: bundle exec good_job start | ||
| js: WEBPACK_PORT=${WEBPACK_PORT:-3035} yarn webpack --watch | ||
| js: WEBPACK_PORT=${WEBPACK_PORT:-3035} ORIGIN_PORT=${ORIGIN_PORT:-3000} yarn webpack --watch |
Contributor
Author
There was a problem hiding this comment.
The reason for creating a separate environment variable copying PORT is that the behavior of Foreman is to assign a different port value for each process (see ddollar/foreman#110, ddollar/foreman#714). If we just passed PORT, it would actually assign 3200, since this is the third process in the Procfile.
zachmargolis
approved these changes
Feb 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠 Summary of changes
Updates local Webpack development server to limit allowed origins for CORS to the expected local web server origin (usually http://localhost:3000).
This is motivated by a security advisory GHSA-67mh-4wv8-2f99 which addresses a similar issue in a package that we don't use in the IdP.
The risk here is fairly minimal, since the dev server only serves files out of the
public/directory.An original approach considered disabling CORS altogether. CORS is enabled because we specify the
crossoriginattribute on script assets in local development, and we specify this attribute because it allows for better error messages in pages using React.js (see #6126).📜 Testing Plan
Verify in local development that there are no issues loading JavaScript. It should be pretty evident if JavaScript is not working, because the "Here's how you know" USA banner will display as expanded by default.