-
I can resolve this by adding I'm currently using node v18.9.0 in mjs mode like: import { installGlobals, broadcastDevReady } from "@remix-run/node"
import { Hono } from "hono"
import { serve } from "@hono/node-server"
import * as rh from "remix-hono/handler"
import * as build from "./build/index.mjs"
installGlobals()
if (process.env.NODE_ENV === "development") broadcastDevReady(build)
const server = new Hono()
server.use(
"*",
rh.remix({
build,
mode: process.env.NODE_ENV,
// getLoadContext is optional, the default function is the same as here
getLoadContext(ctx) {
return ctx.env
},
})
)
serve(server, (info) => {
console.log(`Listening on http://localhost:${info.port}`) // Listening on http://localhost:3000
}) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The way I recommend you to use it by setting the If you do this, you will have to also change: -import * as build from "./build/index.mjs"
+import * as build from "@remix-run/dev/server-build"; |
Beta Was this translation helpful? Give feedback.
-
Got you. After some playing around I've got it working! One addition my server needed for working in node was handling the static files like so: import { serveStatic } from '@hono/node-server/serve-static'
server.get(
'*',
serveStatic({
root: './public',
rewriteRequestPath: (path) => path.replace(/^\/public/, '/'),
})
) |
Beta Was this translation helpful? Give feedback.
The way I recommend you to use it by setting the
server
option in theremix.config
file, this way Remix will take care of bundling the server file (which can also be written in TS) and then you will donode build/index.js
to run it.If you do this, you will have to also change: