rollup-plugin-serve: historyApiFallback not working

Hi, thank you very much for this repo. I want to use the plugin for my new svelte spa app.

My config looks like this:

serve({
    contentBase: 'dist',
    port: 5000,
    historyApiFallback: true
}),

But the historyApiFallback isn’t working. When i go to localhost:5000/solutions/technic i still get 404 Not Found and i don’t see the index.html

How can i solve this?

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Could be interesting to make a repo so we can see what’s going wrong.

when i change the script-tag in the index.html like this: <script src="dist/main.js"></script> it doesn’t work.

Does that mean you removed the leading forward slash? You have to add it, otherwise any request to a nested route like http://example.com/lorem/ipsum will try to load your script from http://example.com/lorem/ipsum/dist/main.js, which is why it fails.

There doesn’t seem to be anything wrong in your rollup.config.js from what I can tell.

@UIX-Design do you have a leading forward slash in your <script src="dist/bundle.js"> on index.html? If not, try to add it. I had the same issue and that fixed it.