How to configure routing for a different base url? like /admin
I'm making good progress building a stand alone admin that I'd like to be part of an app. How can the routing be configured for refine to run under a different route like /admin for ex.
2 Replies
Hi @mephistopheles6125. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To configure routing for a different base URL like
/admin
in a refine application, you can follow these steps based on the provided knowledge sources:
1. Custom Router Component: You can create a custom router component that specifies the base path. This is useful when you want to serve your refine application from a subdirectory.
2. Router Provider Configuration: You need to configure the routerProvider
in your refine setup to use this custom router component.
Here is an example of how you can achieve this:
Step 1: Create a Custom Router Component
Create a custom router component that sets the base path to /admin
.
Step 2: Configure the Router Provider
Pass this custom router component to the routerProvider
in your refine configuration.
Step 3: Define Routes with the Base Path
Ensure that your routes are defined with the base path in mind. For example:
Additional Configuration
If you encounter issues with resources not being prefixed correctly, you can manually prefix the resource paths as a workaround:
References
- Serving the application from a subdirectory (https://github.com/refinedev/refine/issues/3207)
- Base path for resources (https://github.com/refinedev/refine/issues/3953)
- Router Provider Documentation (https://refine.dev/docs/api-reference/core/providers/router-provider/#serving-the-application-from-a-subdirectory)
By following these steps, you should be able to configure your refine application to run under a different route like /admin
.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@908078982681989150> kapa.ai is still learning and improving, please let us know how it did by reacting below