404 Error Create Page
So I created a new route for my organizations for the create resource:
And I created a create.tsx file under my
pages/organization
folder, so it's at pages/organizations/create.tsx
and this is the code for it:
But when i navigate to my organizations/create in my URL, I get a 404 error. But my organization list works just fine.7 Replies
Hi @nick_montoya. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided, it seems like you have not defined the
create
action for your organizations
resource in your resources
array.
In the resources
array, you need to specify the create
action and its corresponding route. Here's how you can do it:
This tells Refine to use the create
action for the route /organizations/create
. Without this, Refine won't know where to find the create page for organizations, hence the 404 error.
Please make sure that your App.tsx
file is correctly set up to use the Refine
component with the dataProvider
, routerProvider
, and resources
props. Here's an example of how it should look:
Please refer to the Refine documentation (https://refine.dev/docs) for more details.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@263527875506995202> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-gold•13mo ago
@kapa.ai Sorry I did place that I just also had edit and show so i removed them to save characters but also accidentally remove the create, so even with the create action, it's still showing a 404 error
Let me check the knowledge base for you. One moment! :books:
----------------------
I see, if you have already defined the
create
action in your resources
array and you're still getting a 404 error, it might be due to how your routing is set up.
In Refine, when components are used to define the resource actions, default paths will be used. You can override the default paths by assigning an object with component
and path
properties to the action properties. The default paths are:
- list
: /resources
- create
: /resources/create
- edit
: /resources/edit/:id
- show
: /resources/show/:id
If you're using a custom router like Next.js or Remix, you might need to set up a catch-all route to handle undefined routes. Here's an example for Next.js:
And here's an example for Remix:
If you're using React Router v6, you can define your actions (list
, create
, edit
, show
, clone
) as paths instead of components. This will allow you to define custom routes for actions and take advantage of the full potential of your router without being restricted to the routes created automatically.
If none of these solutions work, it might be a good idea to check your console for any error messages or warnings that could give you more information about what's going wrong.
For more information, please refer to the Refine documentation (https://refine.dev/docs).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@263527875506995202> kapa.ai is still learning and improving, please let us know how it did by reacting below
jolly-crimson•13mo ago
Did you put the routes in the app file?
For example, with blog-posts of the example
you have this in the Refine component
And then in the routes, you define the routes of every page
stormy-gold•13mo ago
Yes I fixed, i forgot to add that line lol, idk why I was stuck thinking it was going to find it automatically like nextjs