-
Notifications
You must be signed in to change notification settings - Fork 595
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
Usage with http-server #712
Comments
has a good discussion on this topic and the question mark is really important here and will solve it.
Do you think its worth having a section devoted to running a SPA server with choo? I also want to point out that I use something like in my
And that if you do something like this, make sure you point your
Also, it is common to have a BE resource that you want proxied and I want to share how I did this for comment or to help others. const http = require("http"),
httpProxy = require("http-proxy");
const proxy = httpProxy.createProxyServer();
const server = http.createServer(function (req, res) {
if (req.url.indexOf("/api/") > -1) {
proxy.web(req, res, { target: "http://127.0.0.1:5150" });
} else {
proxy.web(req, res, { target: "http://localhost:8080" });
}
});
server.listen(5050); Now your proxy sits behind a router where all requests go into your http/s server on 5050 then requests either go to Now you have both SPA with catchall redirect and BE proxying logic with http-proxy. The author of http-server don't really have a clear focus on serving SPA needs so I think this method might be fill in some needed gaps. |
Expected behavior
from my package.json
This indeed loads up the app properly at
http://127.0.0.1:8080/
However
If i click the link "Join" from within the app, the router properly pushStates to /join and renders the joinView
but if I reload so that the browser tries to request /join... i run into a loop because I'm trying to force http-server to do a catchall and serve my index.html which just has a simple div.
What precisely should I do to handle navigating directly to /join? Without the proxy statement /join doesn't exist because its not really something available outside the SPA.
@YerkoPalma
The text was updated successfully, but these errors were encountered: