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

Single page app #19

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

richard-uk1
Copy link
Contributor

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. :)

This is useful for single page apps where the routing is handled on the
client. I'm using it to serve a webapp using `dodrio`.
@brson
Copy link
Owner

brson commented Jul 1, 2019

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.

@richard-uk1
Copy link
Contributor Author

richard-uk1 commented Jul 2, 2019

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.

Only return the root when the requested file doesn't have an extension.

If the file has an extension, it probably is a file that we should 404.
Adding the extension requirement would break urls like

```
/a/path/with/the/last/part/with.a.dot
```
which might come up in user-created URLs.
@arranf
Copy link

arranf commented Aug 21, 2019

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

@richard-uk1
Copy link
Contributor Author

@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"

@tarkah
Copy link

tarkah commented Jun 11, 2020

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!

@richard-uk1
Copy link
Contributor Author

richard-uk1 commented Jun 11, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants