Gatsby: [gatsby-plugin-offline] pathPrefix, 404

Created on 7 Sep 2018  路  13Comments  路  Source: gatsbyjs/gatsby

another pathPrefix issue,

all pages 404 on subsequent loads

nginx logs when reloading:

213.93.201.49 - - [07/Sep/2018:17:06:55 +0200] "GET /offline-plugin-app-shell-fallback/index.html HTTP/2.0" 404 271 "https://jknr.me/mobiuslabs/sw.js" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36"

Missing pathprefix there!


  System:
    OS: Linux 4.9 Debian GNU/Linux 9 (stretch) 9 (stretch)
    CPU: x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
    Shell: 5.3.1 - /bin/zsh
  Binaries:
    Node: 10.7.0 - ~/.nvm/versions/node/v10.7.0/bin/node
    Yarn: 1.9.4 - ~/.nvm/versions/node/v10.7.0/bin/yarn
    npm: 6.3.0 - ~/.nvm/versions/node/v10.7.0/bin/npm
  Browsers:
    Chrome: 68.0.3440.106
    Firefox: 52.9.0
  npmPackages:
    gatsby: ^2.0.0-rc.13 => 2.0.0-rc.13 
    gatsby-image: ^2.0.0-rc.1 => 2.0.0-rc.1 
    gatsby-node-helpers: ^0.3.0 => 0.3.0 
    gatsby-plugin-google-analytics: ^2.0.0-rc.1 => 2.0.0-rc.1 
    gatsby-plugin-manifest: ^2.0.2-rc.1 => 2.0.2-rc.1 
    gatsby-plugin-offline: ^2.0.0-rc.4 => 2.0.0-rc.4 
    gatsby-plugin-postcss: ^2.0.0-rc.1 => 2.0.0-rc.1 
    gatsby-plugin-react-css-modules: ^2.0.0-rc.1 => 2.0.0-rc.1 
    gatsby-plugin-react-helmet: ^3.0.0-rc.1 => 3.0.0-rc.1 
    gatsby-plugin-sass: ^2.0.0-rc.2 => 2.0.0-rc.2 
    gatsby-plugin-sharp: ^2.0.0-rc.3 => 2.0.0-rc.3 
    gatsby-plugin-typography: ^2.2.0-rc.3 => 2.2.0-rc.3 
    gatsby-source-filesystem: ^2.0.1-rc.1 => 2.0.1-rc.1 
    gatsby-transformer-sharp: ^2.1.1-rc.2 => 2.1.1-rc.2 
  npmGlobalPackages:
    gatsby: 2.0.0-beta.87

confirmed bug

All 13 comments

So your thought here is that (clearly) it loads the first time, but on refresh everything 404s right?

That's the behavior I'm seeing at least. Removing moving parts here... if you remove gatsby-plugin-offline the site works like you'd expect, correct?

That's the first thing I'd do! Just to ensure that that's the issue.

Additionally, it'd be _great_ if you could share a reproduction repo so we could debug for ourselves. It's nice to have the site, but I could debug this a lot more quickly with some source code!

Thanks!

@DSchau correct: https://jknr.me/mobiuslabs/?no-cache=1 works as expected

A repo is not necessary imho: just add pathPrefix to any starter with gatsby-plugin-offline

A repo is not necessary imho

Disagree a lot there, but I went ahead and created one.

I'm ~not~ able to reproduce the issue, but first I just want to make sure we're on the same page here. Here's what I did.

  1. Added gatsby-plugin-offline to gatsby-config.js
  2. Added pathPrefix to gatsby-config.js
  3. Changed build script to use --prefix-paths
  4. Deployed to github pages at a subdomain (gatsby-7967)
  5. Validated that routing works, and routing remains to work on refresh

Anything I'm missing here? Perhaps it's a version mismatch and updating things (e.g. gatsby-plugin-offline) would be helpful here?

Repo | Demo

looks great! it 404s as expected, thank you, @DSchau

i think the issue is here:
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-offline/src/gatsby-node.js#L48

it includes pathPrefix... im not sure if it should

Ha, I re-built the site and I think the issue manifested _after_ I checked. Thanks for fact checking me :)

by the way, should not the html files themselves be included?

edit: ahh here: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-offline/src/gatsby-node.js#L59

Let me see if I can fix this. We're currently working on pathPrefix automated tests so this is something I'll see if I can automate once we fix this too 馃槄

I think I'm about to fix it over here already, i will just slice out the pathPrefix the html assets, is that alright with you?

Happy to have you do it :) Let's just test it with path prefix and without to make sure we haven't introduced a regression!

understood! ok seeya with a pr

Hi @sktt, I'll have a look at this since I've written some of the more recent code for handling 404s with offline-plugin.

Hi there, @davidbailey00! Please have a look at my pr i think the problems are solved

Was this page helpful?
0 / 5 - 0 ratings