basic-http-server icon indicating copy to clipboard operation
basic-http-server copied to clipboard

Single page app

Open richard-uk1 opened this issue 6 years ago • 6 comments

This PR adds an option to redirect all file misses to the path '/index.html'. This is useful for single-page apps where the routing is done client-side. I'm raising this as a draft PR because it's a new feature out of the blue, and you might not want it. :)

richard-uk1 avatar Jul 01 '19 15:07 richard-uk1

I'm happy to accept it.

Can you change the option description to bit though: "Single page app mode (404s are redirected to '/')". Instead of "404s redirected to '/'", "404s respond with '/index.html'". That looks to be more accurate.

It might be reasonable to just enable this whenever -x is on. It doesn't seem to collide with any other behavior.

brson avatar Jul 01 '19 21:07 brson

Glad you like it! Shall we leave it as a separate option for now, then it can always be rolled into -x later? I'll wait until we've worked out the #22 so I can rebase on master.

richard-uk1 avatar Jul 02 '19 10:07 richard-uk1

Is there anything I can do to get this PR pulled in?

arranf avatar Aug 21 '19 09:08 arranf

@arranf You can use my fork for now at

[dependencies.basic-http-server]
git = "https://github.com/derekdreery/basic-http-server"
branch = "single_page_app"

richard-uk1 avatar Aug 21 '19 10:08 richard-uk1

Any update on merging this? I'd really prefer to use this over having to depend on web-pack or the like for developing w/ yew or mogwai. Thanks!

tarkah avatar Jun 11 '20 17:06 tarkah

I'll try to have a look at getting this ready to merge, but in the mean time you can either use my branch, or there is another static dev server crate that serves the index on failure, ~~but I regret I've forgotten it's name~~ microserver.

richard-uk1 avatar Jun 11 '20 18:06 richard-uk1