gatsby: Built site fails when deployed to Amazon S3 in 2.9.0 and later

Description

Site builds and serves successfully with gatsby build && gatsby serve, but when I copy the built files to an AWS S3 web bucket, the site generates ‘resource missing’ errors.

(the same AWS bucket has served gatsby sites successfully in the past)

UPDATE: I believe rolling back in same project to

  "dependencies": {
    "gatsby": "2.8.8",
    ...

fixes the issue. 2.9.0 and later all have the problem)

Steps to reproduce

(1)

gatsby new demo
cd demo
gatsby build

(2) upload files to AWS S3 website-bucket

Expected result

Website should appear as it does from gatsby serve

Actual result

The js does not run. Console shows errors:

Screenshot 2019-06-26 at 13 44 07

According to the ‘Network’ tab of my browser, all files loaded successfully.

Environment

System: OS: macOS 10.14.5 CPU: (4) x64 Intel® Core™ m3-7Y32 CPU @ 1.10GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 12.4.0 - ~/.nvm/versions/node/v12.4.0/bin/node Yarn: 1.16.0 - /usr/local/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v12.4.0/bin/npm Languages: Python: 2.7.10 - /usr/bin/python Browsers: Chrome: 75.0.3770.100 npmPackages: gatsby: ^2.10.4 => 2.10.4 gatsby-image: ^2.2.3 => 2.2.3 gatsby-plugin-manifest: ^2.2.0 => 2.2.0 gatsby-plugin-offline: ^2.2.0 => 2.2.0 gatsby-plugin-react-helmet: ^3.1.0 => 3.1.0 gatsby-plugin-sharp: ^2.2.1 => 2.2.1 gatsby-source-filesystem: ^2.1.0 => 2.1.0 gatsby-transformer-sharp: ^2.2.0 => 2.2.0 npmGlobalPackages: gatsby-cli: 2.7.2

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 20 (6 by maintainers)

Most upvoted comments

is Gatsby’s position that this is an environment issue or will there be thought putting into a gatsby solution

The expectation is currently that people’s servers would set the mime type to application/json but yeah — that’s probably too strict given how many variants there is out there (see e.g. https://stackoverflow.com/questions/477816/what-is-the-correct-json-content-type)

Checking the extension in addition to the mime type seems reasonable — would someone like to PR that in?

Still fails in 2.11.5, but with a different error

Screenshot 2019-06-29 at 21 13 03

(There IS a 404 page)

Still fails in 2.11.0