stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.04k stars 390 forks source link

[heroku] react-snap can't find static js, may be hitting the actual domain? #532

Closed clintandrewhall closed 3 years ago

clintandrewhall commented 3 years ago

see: https://github.com/clintandrewhall/clintandrewhall.com

I've got a weird issue where my Heroku build finishes fine, but react-snap claims to not be able to find the bundle JS:

Creating an optimized production build...
       Compiled successfully.

       File sizes after gzip:

         203.23 KB  build/static/js/2.18db339d.chunk.js
         34.84 KB   build/static/js/main.5c8cc2ec.chunk.js
         20.98 KB   build/static/css/main.937a3a67.chunk.css
         2.8 KB     build/static/css/2.9dd678f7.chunk.css
         1.57 KB    build/static/js/3.c807d26e.chunk.js
         1.19 KB    build/static/js/runtime-main.c75983e0.js

       The project was built assuming it is hosted at https://www.clintandrewhall.com/.
       You can control this with the homepage field in your package.json.

       The build folder is ready to be deployed.

       Find out more about deployment here:

         https://cra.link/deployment

       $ react-snap
       ️️️⚠️  warning at /: got 404 HTTP code for https://www.clintandrewhall.com/static/js/main.5c8cc2ec.chunk.js
       ️️️💬  console.log at /: Failed to load resource: the server responded with a status of 404 (Not Found)
       ️️️⚠️  warning at /: got 404 HTTP code for https://www.clintandrewhall.com/static/js/main.5c8cc2ec.chunk.js
       ️️️💬  console.log at /: Failed to load resource: the server responded with a status of 404 (Not Found)
       ✅  crawled 1 out of 1 (/)
       Done in 97.97s.

I have a suspicion that it's actually hitting clintandrewhall.com, and therefore the previous build? But I'm not sure.

I have everything configured as recommended, but I also have one caveat: I host my resume statically on my site, so I actually have an express server sitting in front, routing to the static build. I don't think that impacts anything, though.

Also of note: everything works fine locally:

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  203.23 KB (-21 B)  build/static/js/2.18db339d.chunk.js
  34.84 KB (+10 B)   build/static/js/main.85a67f9a.chunk.js
  20.91 KB           build/static/css/main.1f878261.chunk.css
  2.8 KB             build/static/css/2.9dd678f7.chunk.css
  1.57 KB            build/static/js/3.c807d26e.chunk.js
  1.17 KB            build/static/js/runtime-main.8831eafa.js

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment

$ react-snap
 ️️️⚠️  warning at /: got 403 HTTP code for https://api.github.com/users/clintandrewhall
 ️️️💬  console.log at /: Failed to load resource: the server responded with a status of 403 ()
 ️️️⚠️  warning at /: got 403 HTTP code for https://api.github.com/users/clintandrewhall/repos
 ️️️💬  console.log at /: Failed to load resource: the server responded with a status of 403 ()
 ️️️💬  console.log at /: API rate limit exceeded for 136.34.146.125. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.) API rate limit exceeded for 136.34.146.125. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
✅  crawled 1 out of 17 (/)
⚠️  warning: 404 page title does not contain "404" string
✅  crawled 2 out of 17 (/404.html)
✅  crawled 3 out of 17 (/resume)
✅  crawled 4 out of 17 (/portfolio/node)
✅  crawled 5 out of 17 (/portfolio/swarm)
✅  crawled 6 out of 17 (/portfolio/facebook)
✅  crawled 7 out of 17 (/portfolio/node-foursquare)
✅  crawled 8 out of 17 (/portfolio/event-wall)
✅  crawled 9 out of 17 (/portfolio/backstrokes)
✅  crawled 10 out of 17 (/portfolio/tedx)
✅  crawled 11 out of 17 (/portfolio/web)
✅  crawled 12 out of 17 (/portfolio/node-knockout)
✅  crawled 13 out of 17 (/portfolio/metaphorically)
✅  crawled 14 out of 17 (/portfolio/cerner)
✅  crawled 15 out of 17 (/portfolio/guess-friends)
✅  crawled 17 out of 19 (/portfolio/web-bootstrapper)
✅  crawled 18 out of 20 (/portfolio)
✅  crawled 19 out of 20 (/pdf/web-bootstrapper-deck.pdf)
✅  crawled 20 out of 20 (/portfolio/)
✨  Done in 38.91s.
clintandrewhall commented 3 years ago

Solved it... in case anyone else has this issue, I had set PUBLIC_URL, which added the domain to all paths in the source HTML. Removing that allowed react-snap to work against the new build, instead of the version already deployed.