简体   繁体   中英

Web Manifest goes into redirect loop

I'm looking at potential of using PWA, however when I put a manifest.webmanifest it ends up in a redirect loop and results in the browser returning a "Too many redirects error", this is the only resource which is doing this, I'm loading other resources, such as CSS, JS, Images, Favicon, robots.txt using the same method and not getting an issue

The server is running on localhost:8080 using HTTPS and HTTP/2

The Chrome DevTools console shows
GET https://localhost:8080/manifest.webmanifest net::ERR_TOO_MANY_REDIRECTS

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Title</title>
    <meta name="description" content="Meta Description">
    <link rel="manifest" href="/manifest.webmanifest">
    <link rel="stylesheet" href="/assets/uikit-3.5.9/css/uikit.min.css">
    <link rel="stylesheet" href="/assets/css/app.min.css">
</head>

The manifest file itself is served by the web server which is written in Go using Gorilla Mux

r.PathPrefix("/manifest.webmanifest").Handler(http.FileServer(http.Dir(os.Getenv("PUBLIC_ROOT"))))

I have also tried using HandleFunc to construct and serve the manifest as well, but this results in a redirect loop as well.

If I navigate directly to the manifest in the browser it successfully loads successfully (without any redirects showing in the chrome dev tools)

manifest.webmanifest 直接导航时

Below is a screenshot of the chrome dev tools when navigating the website

Chrome 开发工具

Not sure how or why, but the issue seemed to be within the session middleware where a Cookie was being set against the webmanifest link

By excluding the URL for the manifest from the session manager the issue has gone away

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM