Closed mightymercado closed 4 years ago
No it doesnt. Please explain what you're trying to do
Normally, sirv serves your static files using HTTP. Is there a way to serve it using https?
If you mean sirv-cli
(the CLI), then refer here: https://github.com/lukeed/sirv/tree/master/packages/sirv-cli#http2
If you mean sirv
itself (the middleware), then no, because it's a handler/middleware function that runs in your existing server. The simplest thing you can do is:
const { createServer } = require('https');
const { readFileSync } = require('fs');
const options = {
key: readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: readFileSync('test/fixtures/keys/agent2-cert.pem')
};
const handler = require('sirv')('public');
createServer(options, handler).listen(PORT);
The sirv-cli
package effectively does this, but better, through the http2
module.
Hope that helps~!
Thanks! It worked. Had to update sirv-cli to 1.0.1 because my-svelte-project
template was using an older version. It would be great if there was an -adhoc
option that does the certificates automatically!
Ah ya, it only exists in 1.x -- PRs are open to update those templates.
Will not auto scaffold certificates because there are 100 tools that already do that, and it's very system-specific
Title says it all.