mars / create-react-app-buildpack

⚛️ Heroku Buildpack for create-react-app: static hosting for React.js web apps
MIT License
3.28k stars 653 forks source link

Configure to serve .gz file with HTTP Response Header "Content-Encoding: gzip" #199

Closed leolambo closed 2 years ago

leolambo commented 2 years ago

I am trying to parse a .gz file to be able to run WebGL code present in my react app. I am getting the following error

Unable to parse /build/file.framework.js.gz! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: gzip" present. Check browser Console and Devtools Network tab to debug.

"Content-Encoding" is missing altogether and "Content-Type" is not gzip. My response header looks like this:

HTTP/1.1 200 OK Connection: keep-alive Server: nginx Date: XXXXXXXX Content-Type: application/octet-stream Content-Length: 91235 Last-Modified: XXXXXXXX Etag: "XXXXXXX-XXXXX" Accept-Ranges: bytes Via: 1.1 vegur

is there any way I can configure the static.json to ensure the correct encoding is present and this error resolves?

mars commented 2 years ago

Yes, response headers are configurable. The README section for customizing the web server links to the static web server docs:

Custom Headers

Using the headers key, you can set custom response headers.