now at https://github.com/atmos-inc/api/pull/4930/files
yarn add @remix-run/node @mcansh/remix-raw-http @hapi/inert
cd web
remove { ssr: false } from vite.config.js
yarn build
move web/build/client/assets to /assets
// routes/app.mjs
import * as build from '../web/build/server/index.js'
import { createRequestHandler } from '@mcansh/remix-raw-http'
export default [
{
method: 'GET',
path: '/{path*}',
options: {
auth: false
},
handler: (request, h) => {
const handler = createRequestHandler({
build,
mode: build.mode
})
return handler(request.raw.req, request.raw.res)
}
},
{
method: 'GET',
path: '/assets/{filename}',
options: {
auth: false
},
handler: (request, h) => {
return h.file(`${request.params.filename}`)
}
}
]
Hapi route for mounting built remix app in prod, according to https://github.com/mcansh/remix-node-http-server/blob/main/example/server.js
// index.mjs
import hapiInert from '@hapi/inert'
...
files: {
relativeTo: path.join(__dirname, 'web/build/client/assets')
}
...
await server.register(hapiInert) // and remove realm
...
if (file !== 'routes/app.mjs') {
r.default.map(r => (r.path = `${config.server.api_path}${r.path}`))
}