Remix app erroring out with message - Initial URL (/) does not match URL at time of hydration (/deployment/my-portal-ui/), reloading page... #7018
-
Hi all, I have remix app having express adapter which is deployed at the path - Please note that I have updated publicPath in remix.config.js file as-
Now when I am running app it renders the page momentarily but then page refreshes indefinitely and giving below error -
I have similar use case as this #6785 and I see comment by @brophdawg11
Do we have any solution/work around to handle this issue. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
The issue is that your routes don't match the URL. Remix doesn't support URL rewriting. However, you could update your routes so it has the extra top-level paths as part of the config. There are a couple of ways to do that. The first is to just update your routes to add those folders directly: Granted, that only works if those top-level paths are static. The other option is to use my package const { flatRoutes } = require('remix-flat-routes')
/**
* @type {import("@remix-run/dev").AppConfig}
*/
const BASE_PATH = '/deployment/my-portal-ui'
module.exports = {
// ignore all files in routes folder to prevent
// default remix convention from picking up routes
ignoredRouteFiles: ['**/*'],
publicPath: `${BASE_PATH}/build/`,
routes: async defineRoutes => {
return flatRoutes('routes', defineRoutes, { basePath: BASE_PATH })
},
} |
Beta Was this translation helpful? Give feedback.
-
Thanks @kiliman for your input. The original error message is gone but now some other error is coming with same page refresh indefinitely. Application Error Here is my remix.config.js file --
|
Beta Was this translation helpful? Give feedback.
-
I found a filthy hack that fixes this issue In root.tsx
|
Beta Was this translation helpful? Give feedback.
The issue is that your routes don't match the URL. Remix doesn't support URL rewriting.
However, you could update your routes so it has the extra top-level paths as part of the config.
There are a couple of ways to do that. The first is to just update your routes to add those folders directly:
routes/deployment.my-portal-ui._index.tsx
Granted, that only works if those top-level paths are static.
The other option is to use my package
remix-flat-routes
. It's a superset of the newv2
flat routes convention. It includes some enhancements, with one of them being the ability to set thebasePath
. This will automatically add thebasePath
to all the top level routes in your app.