kiliman/remix-flat-routes

custom server (express) routes not resolved

Closed this issue · 1 comments

remix config:

import {flatRoutes} from "remix-flat-routes"

/** @type {import('@remix-run/dev').AppConfig} */
export default {
    ignoredRouteFiles: ["**/.*", "**/*.test.{js,jsx,ts,tsx}"],
    routes: async defineRoutes=>{
        return flatRoutes('routes', defineRoutes )
    },
    publicPath: "/_static/",
    server: "server.mjs",
    serverModuleFormat: "esm"
};
server taken from:
https://remix.run/docs/en/main/future/vite#migrating-a-custom-server



routes:

_auth+
 └── login.tsx

got
Error: No route matches URL "/login"

if remove server: "server.mjs", from config works fine.

should I add something to server to support it?

If you're using Vite, you need to move this config to vite.config.ts

export default defineConfig({
  plugins: [
    remix({
      ignoredRouteFiles: ["**/*"], // ignore everything from default convention
      routes: async defineRoutes=>{
          return flatRoutes('routes', defineRoutes, {
            ignoredRouteFiles: ["**/.*", "**/*.test.{js,jsx,ts,tsx}"]
          })
      },
      publicPath: "/_static/",
      server: "server.mjs",
      serverModuleFormat: "esm"
    }),
    tsconfigPaths(),
  ],
});