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
net/http: provide an option to access /index.html directly without 301 redirect #53870
Comments
CC @neild |
you could just use |
@seankhliao This is not my own PWA app, I think it is unreasonable and unacceptable to modify someone else's code(e.g., https://github.com/mdn/pwa-examples). Imagine other scenario, I want |
I think it's reasonable to want an One thought might be to only redirect an |
…out 301 redirect For: golang#53870 BREAKING CHANGES: http.ServeFile won't redirect /index.html
…out 301 redirect For: golang#53870 BREAKING CHANGES: http.ServeFile won't redirect /index.html
…out 301 redirect For: golang#53870 BREAKING CHANGES: http.ServeFile won't redirect /index.html
I think the easiest way to do this is to provide an optional chained method like this:
8a1fd33#diff-334dd14b9fe9d920086cc14ef1a9f13ac90972a7b289b944d00d4a9be6891a98R23 |
…out 301 redirect For: golang#53870 BREAKING CHANGES: http.ServeFile won't redirect /index.html
In the spirit of func StripIndex(h http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request {
r.URL.Path = strings.TrimSuffix(r.URL.Path, "index.html")
h.ServeHTTP(rw, r)
})
} |
This is some like what I did in hack GONIC code:
It works well, but I think injecting logic into every request is not so KISS——— |
What version of Go are you using (
go version
)?What did you do?
I found that https://github.com/golang/go/blob/master/src/net/http/fs.go#L590 will redirect
/index.html
to/
with 301 status code.This 301 action may cause some problems for service worker's cache(https://stackoverflow.com/questions/40476938/service-worker-breaking-301-redirects)
What did you expect to see?
PWA(web app) could cache the
start_url:"/index.html"
(301 redirect)What did you see instead?
Since Service Worker breaking 301 redirects, my PWA app can't cache the
start_url:"/index.html"
I think it's better to have an option an option to access
/index.html
directly without 301 redirect. (If possible, I could submit a PR)The text was updated successfully, but these errors were encountered: