Curious what others are doing with SvelteKit adapter-node builds to put them into production.
For example...
- Serving pre-compressed files
- Setting a cache TTL
- Maybe something like
helmet
Is it better to define an entryPoint for the adapter like a server.js that implements polka/express/connect like this...
// src/server.js
import { assetsMiddleware, prerenderedMiddleware, kitMiddleware } from '../build/middlewares.js'
import polka from 'polka'
import compression from 'compression'
import helmet from 'helmet'
const app = polka()
app.use(helmet())
app.use(assetsMiddleware, prerenderedMiddleware, kitMiddleware)
app.use(compression())
app.listen(3000)
or is it better to implement similar functionality in the handler() method of hooks.js?
Interested to know what people are doing to go from a build via adapter-node to production.
After examining what adapter-node generates in the build folder, I decided to set the entryPoint property for the adapter's options in svelte.config.js to
./src/server.mjswhich gets added to the build. The handle() method in hooks.js/ts doesn't allow for any control over the static content.In the code below, I set a redirect for non-https and use helmet to beef up security.