Skip to content
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

STCLI-247 overwrite CORS headers in proxy responses #351

Merged
merged 5 commits into from
Sep 16, 2024
Merged

Conversation

zburke
Copy link
Member

@zburke zburke commented Aug 22, 2024

There are two features here:

  1. provide new CLI option --proxyUrl to allow use of a hostname other than localhost, allowing the machine hosting the bundle to be accessed remotely (e.g. from a conference room, or by a colleague in another office, etc etc)
  2. overwrite CORS headers between the proxy and browser, satisfying the browser that CORS requirements are being met (shhhhh)

Details on Part 2:

Overwrite the following CORS headers between the proxy and browser:

Access-Control-Allow-Origin: http://localhost:${PORT}
Access-Control-Allow-Credentials: true

The ACAO value is commonly set to * for un-credentialed requests (i.e. those without cookies), but as MDN docs for CORS notes:

When responding to a credentialed requests request, the server must specify an origin in the value of the Access-Control-Allow-Origin header, instead of specifying the “*” wildcard. Likewise, the ACAC value is commonly set to "" for uncredentialed requests, but must be set to true to allow cookies to pass through.

These CORS settings appear to have been in place before RTR was introduced, and may still be in place in some backend environments. Overriding these values in the local proxy is a prudent way to allow local development to continue while waiting for the backend settings to catch up.

Refs STCLI-247

Copy link

github-actions bot commented Aug 22, 2024

Jest Unit Test Statistics

0 tests  ±0   0 ✔️ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ±0 

Results for commit acbd72e. ± Comparison against base commit 48e31cc.

♻️ This comment has been updated with latest results.

zburke and others added 2 commits September 13, 2024 17:05
…ort. (#352)

Use case, per @kaladay:

This allows a workstation with a static IP to
1. serve as the proxy and
2. host the corresponding bundle for a third party, e.g. a demo machine
   in another room, a colleague in another office

Co-authored-by: Kevin Day <[email protected]>
Copy link

sonarcloud bot commented Sep 13, 2024

@zburke zburke merged commit 272de3e into master Sep 16, 2024
5 checks passed
@zburke zburke deleted the proxy-strip-acao branch September 16, 2024 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants