You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm in progress migrating from remix
going hard =)
now I have many issues which looks like:
[commonjs--resolver] Server-only module referenced by client
'~/lib/auth.server' imported by route 'app/root.tsx'
React Router automatically removes server-code from these exports:
`loader`, `action`, `unstable_middleware`, `headers`
But other route exports in 'app/root.tsx' depend on '~/lib/auth.server'.
it was worked fin in remix, but now for some reason broken
at same time in remix I used server.mjs and if I started migrated app- its running fine
//import './instrumentation.server.mjs';
const {
PORT
} = process.env
import "./app/src/config.mjs"
import { createRequestHandler } from "@react-router/express";
import express from "express";
import connect from "./app/src/db/connector.mjs";
import {api} from "./app/src/router.mjs";
const viteDevServer =
process.env.NODE_ENV === "production"
? undefined
: await import("vite").then((vite) =>
vite.createServer({
server: { middlewareMode: true },
})
);
const app = express();
app.use("/api", api)
if( process.env.NODE_ENV !== "production"){
// handle asset requests
if (viteDevServer) {
app.use(viteDevServer.middlewares);
} else {
app.use(
"/assets",
express.static("build/client/assets", {
immutable: true,
maxAge: "1y",
})
);
}
app.use( "/_static",
express.static("build/client", { maxAge: "1h" }));
}
// handle SSR requests
app.all(
/(.*)/,
createRequestHandler({
build: viteDevServer
? () =>
viteDevServer.ssrLoadModule(
"virtual:react-router/server-build"
)
: await import("./build/server/index.js"),
})
);
connect()
.then(()=>{
app.listen(PORT, () => {
console.log(`API Listening on port ${PORT}`)
})
})
.catch(
(error) => {
console.error(error)
if (error) throw new Error(`Mongoose could not connect ${error}`)
else console.log('Connected to MongoDB')
})
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm in progress migrating from remix
going hard =)
now I have many issues which looks like:
it was worked fin in remix, but now for some reason broken
at same time in remix I used server.mjs and if I started migrated app- its running fine
Beta Was this translation helpful? Give feedback.
All reactions