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

feat(react): add proxy config support to file-server executor #9225

Conversation

austinhappel
Copy link
Contributor

@austinhappel austinhappel commented Mar 7, 2022

Current Behavior

The file-server executor uses the http-server library under the hood. http-server uses http-proxy under the hood, when handling things like custom SSL certificates.

Currently, when supplying your own SSL certificate (using ssl, sslKey, sslCert and proxyUrl options) with a single-page-app that handles its own routing, http-server will not correctly route paths back to the SPA. As a result, directly visiting paths like /user/login will fail with an authentication error.

In other words: When serving a SPA using custom SSL certificates, directly visiting url paths other than / results in an authentication error response from the server.

The reason for this issue is because the underlying http-proxy isn't configured to correctly handle the custom SSL certificates. Currently it cannot be correctly configured, because this executor does not support accepting configuration settings for the http-proxy. Specifically, it does not support the --proxyOptions argument in http-proxy.

Expected Behavior

When serving a SPA using custom SSL certificates, directly visiting url paths will now work correctly, given the settings are correct.

Example settings that work:

// workspace.json 
"serve": {
  "executor": "@nrwl/web:file-server",
  "options": {
    "buildTarget": "my:target",
    "port": 9040,
    "host": "myHost.com",
    "ssl": true,
    "sslKey": "myHost.key",
    "sslCert": "myHost.crt",
    "proxyUrl": "https://myHost.com:9040?",
    "proxyConfig": "./proxy.conf.json"
  }
},
// proxy.conf.json
{
  "secure": false
}

Related Issue(s)

🤷🏻‍♀️

Fixes #
🤷🏻‍♀️

@nx-cloud
Copy link

nx-cloud bot commented Mar 7, 2022

☁️ Nx Cloud Report

CI ran the following commands for commit 5015907. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 7 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented Mar 7, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nrwl/nx-dev/BwNCHmNeSecT4PeWWdJjdC5kn74H
✅ Preview: https://nx-dev-git-fork-austinhappel-austinhappel-add-proxy-360264-nrwl.vercel.app

[Deployment for 5015907 canceled]

@FrozenPandaz FrozenPandaz changed the title feat(nx-plugin): add proxy config support to file-server executor feat(react): add proxy config support to file-server executor Mar 8, 2022
@austinhappel austinhappel force-pushed the austinhappel/add-proxy-options-to-file-server branch from c6c794d to 98dae05 Compare March 9, 2022 19:33
@austinhappel austinhappel force-pushed the austinhappel/add-proxy-options-to-file-server branch from 98dae05 to 7b53a53 Compare March 9, 2022 19:42
@austinhappel austinhappel force-pushed the austinhappel/add-proxy-options-to-file-server branch from 7b53a53 to 94e406f Compare March 9, 2022 20:02
@austinhappel austinhappel force-pushed the austinhappel/add-proxy-options-to-file-server branch from 94e406f to 18438ac Compare March 9, 2022 21:14
@FrozenPandaz FrozenPandaz force-pushed the austinhappel/add-proxy-options-to-file-server branch from 18438ac to 5015907 Compare March 15, 2022 19:32
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants