graceful-blue
graceful-blue10mo ago

Page Not Found when deployed in Netlify

Hi guys. I’m having a 404 (Not Found) error when I’m trying to run the simple tutorial blog site
No description
5 Replies
kapa.ai
kapa.ai10mo ago
Hi @arsser.. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In refine, handling 404 errors has changed in recent versions. Previously, if authProvider was defined, users were redirected to the /login route even with 404s, and 404 pages were only available to authenticated users. Now, the routes are handled by the users, so you can handle the 404s however you like. If you're using Remix, you can use a splat ($) route to handle the 404s. Here's an example of how to do it:
// Using `loader`
// app/routes/$.tsx
import { json, LoaderFunction } from "@remix-run/node";

export const loader: LoaderFunction = async ({ params, request, context }) => {
return json({}, { status: 404 });
};

// Using `Authenticated`
// app/routes/$.tsx
import { Authenticated } from "@refinedev/core";

export default function NotFound() {
return (
<Authenticated>
<div>I'm the 404 page for the authenticated users.</div>
</Authenticated>
);
}
// Using `loader`
// app/routes/$.tsx
import { json, LoaderFunction } from "@remix-run/node";

export const loader: LoaderFunction = async ({ params, request, context }) => {
return json({}, { status: 404 });
};

// Using `Authenticated`
// app/routes/$.tsx
import { Authenticated } from "@refinedev/core";

export default function NotFound() {
return (
<Authenticated>
<div>I'm the 404 page for the authenticated users.</div>
</Authenticated>
);
}
You can check out the remix docs (https://remix.run/docs/en/main/guides/routing#md-splats) for more information. If you're using Next.js, you can create a 404.tsx file in your /pages directory and it will be used as the 404 page. For more information, you can check the Next.js documentation for custom 404 page (https://nextjs.org/docs/advanced-features/custom-error-page#404-page). Sources: - Remix 404 handling in refine (https://refine.dev/docs/packages/documentation/routers/remix/) - Next.js 404 handling in refine (https://refine.dev/docs/packages/documentation/routers/nextjs/) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai10mo ago
<@1104319194608193577> kapa.ai is still learning and improving, please let us know how it did by reacting below
graceful-blue
graceful-blue10mo ago
Didn't solve my problem. My question is why there is an error when deploying on Netlify. @kapa.ai
kapa.ai
kapa.ai10mo ago
Let me check the knowledge base for you. One moment! :books: Sorry @arsser., I seem to be having a bit of trouble. Don't worry though, I've pinged my supprt and they will try to fix me up! :technologist: Perhaps try again in 15mins?
xenial-black
xenial-black10mo ago
Hello @arsser. you should check netlify deploy logs, generally make sure you run npm run build and see if it fails. Then you can start dev server from built app to check if there are any errors causing this.