Skip to content

Commit

Permalink
fix: 🐛 show not found when deployed
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-guzman committed Oct 29, 2024
1 parent 6fa1ce4 commit 4ddd5b2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
10 changes: 10 additions & 0 deletions e2e/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ test("has title", async ({ page }) => {
await expect(page).toHaveTitle(/React Starter/);
});

test("not found", async ({ page }) => {
await page.goto("/lost");

await expect(page).toHaveTitle(/React Starter/);

await expect(
page.getByRole("heading", { name: "Error", level: 1 }),
).toBeInViewport();
});

test.describe("external links", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/");
Expand Down
4 changes: 2 additions & 2 deletions src/pages/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const Error = ({ error }: ErrorComponentProps) => {
<div className="dsy-hero">
<div className="dsy-hero-content text-center">
<div className="max-w-md">
<h1 className="mb-5 text-5xl font-bold opacity-10 lg:text-7xl xl:text-9xl">
<h1 className="mb-5 text-5xl font-bold lg:text-7xl xl:text-9xl">
Error
</h1>
<p className="mb-5">{error.message}</p>
<p className="mb-5 text-error">{error.message}</p>
<Link className="dsy-btn dsy-btn-outline" to="/">
Go back
</Link>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const NotFound = () => {
<div className="dsy-hero">
<div className="dsy-hero-content text-center">
<div className="max-w-md">
<h1 className="mb-5 text-5xl font-bold opacity-10 lg:text-7xl xl:text-9xl">
<h1 className="mb-5 text-5xl font-bold lg:text-7xl xl:text-9xl">
Error
</h1>
<p className="mb-5">Not Found</p>
<p className="mb-5 text-error">Not Found</p>
<Link className="dsy-btn dsy-btn-outline" to="/">
Go back
</Link>
Expand Down
4 changes: 3 additions & 1 deletion src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ const Root = () => {
);
};

export const Route = createRootRouteWithContext()({ component: Root });
export const Route = createRootRouteWithContext()({
component: Root,
});
8 changes: 8 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rewrites": [
{
"source": "/(.*)",
"destination": "/"
}
]
}

0 comments on commit 4ddd5b2

Please sign in to comment.