firebase / superstatic

Superstatic: a static file server for fancy apps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

3.0.0 regression bug: /__/env.js returns content, but with 404 error code

greghuc opened this issue · comments

What's the problem?

I'm running Superstatic as connect middleware. On upgrading to 3.0.0 from 2.2.2, browser requests to /__/env.js are 404ing. But the correct content is returned in the response.

What's the correct behaviour?

Browser requests to /__/env.js should return content, and 200 OK. As before.

Why should this be fixed?

It's broken, which means that running Divshot/Connect on a developer desktop is busted. This may affect quite a few Divshot customers.

I ran into this when attempting to migrate from Divshot to Firebase - I wanted the latest version of superstatic before starting.
I'm postponing the migration for now.

Any else useful?

Coffeescript file used to run server:

fs = require 'fs'
connect = require 'connect'
superstatic = require 'superstatic'
https = require 'https'

keyFile = process.argv[2]
certFile = process.argv[3]

console.log "Key file: #{keyFile}"
console.log "Cert file: #{certFile}"

app = connect().use superstatic(
  config:
    cache_control:
      '/**': false
  env:
    envName: 'development'
)

options =
  key: fs.readFileSync keyFile
  cert: fs.readFileSync certFile

https.createServer(options, app).listen 4200

Divshot config file:

{
    "name": "PLACEHOLDER",
    "root": "build",
    "clean_urls": false,
    "routes": {},
    "headers": {
        "/**": {
            "X-Robots-Tag": "noindex, nofollow"
        }
    },
    "error_page": "error.html",
    "exclude": []
}

Thanks, and congrats on Firebase merge!

Greg

I think I'm seeing something related. If I add the following to my index.html, I get a 404 error

<script src='/__/env.js'></script>

However, if I copy the exact URL that Chrome tried to reach and access it directly, it loads the JS file just fine. Note, I am not using superstatic as middleware but rather just using it directly from the command line.

Edit: The problem only happens with the latest version from NPM. If I install 2.2.2 directly, it's fine.

👍

Seeing this too with superstatic as middleware.

Can confirm that this is probably a regression. I'm actually doing some pretty substantial refactoring of the guts of Superstatic right now which will take a bit of time. My recommendation would be to stick with 2.x for middleware uses and env.js until a new version is ready.

@mbleigh any news on fixing this bug for superstatic as middleware? I just received the email suggesting I migrate to Firebase by Dec 22.

@greghuc Firebase Hosting does not have direct support for Superstatic-style environment variables, so regardless of this bug you'll need to find another approach. I wrote a blog post detailing some of the techniques you can use to achieve similar results with Firebase Hosting.

This will be fixed by Superstatic 4.0 which is coming soon (keep an eye on #187 for progress).

Closed by 4.0!