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
parcel dev server will serve index.html when --public-url
is set to ./
(dev server will serve index.html to anything unrecognized)
#1354
Comments
This is to support Single Page Applications, as these might have internal front-end routing, that can't work without redirecting everything to the index.html file |
Thanks for your reply. but is serve index.html with request like That said, I think adding a flag like |
Perhaps we can see if the extension of the request equals one of the types parcel has registered (in the parser) and return a 404 or the actual asset in that case? |
This solution fits my use case perfectly, but I am not really a frontend expert. Not sure if this will break somebody else's setup. |
maybe that could be non-default behaviour enabled by |
I'm running into this issue as well even on just the index page. I guess my question is why is this considered an unknown path? When on |
running into this as well I use parcel to build a simple html css js page (using it for minification, autoprefixer, scss, etc.) Just noticed the multiple page support so decided to add a On github pages all works as expected (going to the root path servers Is this the expected behaviour? |
I too am looking for a |
In case this helps anyone, I used const { createProxyMiddleware } = require("http-proxy-middleware");
module.exports = function (app) {
app.use(
createProxyMiddleware(
(path) => path.match(/^\/foo\/?$/),
{
target: "http://localhost:1234/",
pathRewrite: { "/foo": "/foo/index.html" },
})
);
}; Make sure to include the |
I think my problem is related to this: I've never been able to view anything other than my I'm going to workaround it by running |
HTML files other than `index.html` have never worked properly with `parcel serve`, as in they could not be accessed. Turns out that it's designed solely for [SPAs], which is a strange choice and is incompatible with this 'traditional' site. This changes Parcel usage to only `watch`, and instead uses the [serve] as the server. The port changes from `1234` to `5000` (serve's default); the former is still used by `parcel watch` to provide the websocket for Hot Module Replacement. [serve]: https://www.npmjs.com/package/serve [SPAs]: parcel-bundler/parcel#1354 (comment)
Certainly some SPAs need this behavior, but it's odd there's no flag to behave like a normal HTTP server. |
🐛 bug report
As title. I have used
--public-url ./
as a temporary workaround within VSCode's sourcemap behavior documented here. This will made asset linked within compiled html from<script src="/js.8e7f6a41.js">
to<script src="js.8e7f6a41.js">
. Without the slash the dev server will consider this unknown path and serve index.html. By using other dev server solution likehttp-server
to servedist
will not exhibit such problem.I believe this behavior is more confusing than helpful to most users.
🤔 Expected Behavior
Have dev server act more similarly to regular http server than automatically try to 'correct' unknown path
😯 Current Behavior
Dev server will serve any path unregonized with index.html, and many magic seems to be confusing to me.
The text was updated successfully, but these errors were encountered: