kiliman / remix-flat-routes

Remix package to define routes using the flat-routes convention
MIT License
640 stars 22 forks source link

Make hybrid route character configurable #57

Open ZipBrandon opened 1 year ago

ZipBrandon commented 1 year ago

Thanks for creating this. I love this approach to v2 routing. I converted my application over to embrace it and unfortunately when I deployed on S3 my route files were 404/AccessDenied. I delved into this further and even though I can create a path in the bucket with the +, S3 requires those assets to be requested with the + URL encoded to %3D. I asked in Remix Discord if there was a way to rewrite asset imports but there isn't. I had to resolve my problem using a terminal - convention instead of the terminal + and hard-coded - into my clone of the repo. If this issue is of wider appeal and I'm not missing anything obvious, I can work a proper PR for configurability of this.

kiliman commented 1 year ago

Interesting. So it's trying to access the build assets? Seems like something Remix or esbuild should handle then.

Anyway you're asking if I can add an option to configure the + suffix? That should be easy. I already do that for the $ prefix.

ld-kyee commented 8 months ago

Hi, I'm also having this issue, are there any updates for this pr? https://github.com/kiliman/remix-flat-routes/pull/70

kiliman commented 1 week ago

Here's a temporary workaround:

{
  routes: async defineRoutes => {
    const routes = flatRoutes('routes', defineRoutes)
    // remove + in route ids
    const newRoutes = {}
    Object.entries(routes).forEach(([routeId, route]) => {
      route.id = routeId.replaceAll('+', '')
      if (route.parentId) {
        route.parentId = route.parentId.replaceAll('+', '')
      }
      newRoutes[route.id] = route
    })
    return newRoutes
  },
}