-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any support for base, base_url or basename? #102
Comments
Hey @carlvoller, thanks for your comment! Yes indeed, the The prefixed Here's a reference to the updates needed to achieve what you wanted: // vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import generouted from '@generouted/react-router/plugin'
export default defineConfig({
plugins: [react(), generouted()],
base: '/sub/',
}) For the router // src/main.tsx
import { createRoot } from 'react-dom/client'
import { RouterProvider, createBrowserRouter } from 'react-router-dom'
import { routes } from '@generouted/react-router'
const Routes = () => <RouterProvider router={createBrowserRouter(routes, { basename: '/sub' })} />
const container = document.getElementById('app')!
createRoot(container).render(<Routes />) Here's an example the pages matching the
Hope that helps, have a nice day! |
Hi @oedotme, That did the trick! Thank you so much for your help! I really appreciate it. Have a great day to you too 👍 |
Hi, I was wondering if this project had any way to implement support for Vite's
base
or react-router'sbasename
properties. I can't deploy my site at the root of the domain and need to set a subdirectory as the root instead. I tried following the react-router-custom-path example but I don't think that quite supports my need.Ideally what I want to achieve is when the user navigates to
/subdirectory/
, they should be returned the page in/src/pages/index.tsx
. I tried creating a custom router inroutes.tsx
to set thebasename
property oncreateBrowserRouter()
but that doesn't appear to route the files in/src/pages
correctly.Would really appreciate some guidance on this, this project is so close to perfect for me! Thank you for your time, I hope your day has been great!
My current
routes.tsx
for reference:The text was updated successfully, but these errors were encountered: