Support static.json

I believe I’ve seen it on some Heroku buildpacks for static content. It will make it easy for people to setup their static sites on Glitch without messing with package.json and server.js and learning a lot of details about NPM, Node.js, serving requests etc.

{
	"root": "www",
	"https_only": true,
	"headers": {
		"/**": {
			"Access-Control-Allow-Origin": "*",
			"Strict-Transport-Security": "max-age=31536000; includeSubdomains;"
		}
	}
}
1 Like

To serve a static site you can currently just remove make sure package.json is deleted from the project. The static server kicks on automatically.

3 Likes

On that note it might be a good idea to mention this fact in the default README.md.

4 Likes

I think @techtonik wants to be able to specify headers and the other features in the static.json file.

2 Likes

Well, yes. Our https://github.com/gratipay/grtp.co is a static site, but it is build by JS tools from package.json, so removing it is not an option.

1 Like

It’s not the cleanest solution and doesn’t account for the Strict-Transport-Security you’ve specified in your static.json though so it may not work for this particular project…but, if anyone else is experiencing a similar issue and wants to use Glitch the fastest workaround without having to completely delete package.json would be to update the start script in package.json.

"start": "ws --port 3000 --directory ./www --forbid '/.env' --forbid '/.data' --log-format combined",
2 Likes