Next.js Discord

Discord Forum

router redirection not working??

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Avatar
Polar bearOP
Hello !

My router dosnt redirect to /board/${data.id} as intended on my form-popover file. It should show me a 404page cause i didnt created the page for now witch is normal. Ive tried alot of things to debug but i could not find the solution for several days now. I tried console logging the link, and when its pasted it shows that404 page . I also tried downgrading the version of next but dosnt changed. I am realy lost there.

my repo : https://github.com/SHOOTSTV/trello-clone

my prisma schema aswel :


generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}

model Board {
id String @id @default(uuid())
orgId String
title String
imageId String
imageThumbUrl String @db.Text
imageFullUrl String @db.Text
imageUserName String @db.Text
imageLinkHtml String @db.Text

createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Image

59 Replies

Avatar
@Alfonsus Ardani where is your form popover file?
Avatar
Polar bearOP
here
Image
. /components/form/form-popover.tsx
Avatar
i checked everywhere
there is no route /board
Image
@Polar bear
Avatar
@Alfonsus Ardani i checked everywhere
Avatar
Polar bearOP
As of now yes because on the tutorial im watching it is supposed to redirect to 404 page and thΓ© when I create it it does work
Avatar
okayy um so what doesn't work?
Avatar
Polar bearOP
I didnt pushed the version that I did created the route but it does nothing at all
Even if I created it
Avatar
@Alfonsus Ardani okayy um so what doesn't work?
Avatar
Polar bearOP
It looks like it dosnt even redirect to 404 page
Like its Frozen or something
Avatar
can you send like the latest code..
Avatar
Polar bearOP
Yes I will do it soon as im back home πŸ™, thank you for your Time
Avatar
I see, safe driving. It would be nice next time if you can send a proper context if you want to ask help πŸ™
Avatar
Polar bearOP
Yes I understand. I am sort of new to coding so I dont have the proper wording sometimes
Sorry for that, i struggle to write What the problem actualy is
Avatar
I see, then we will look at it together and which part doesn't work
Avatar
Polar bearOP
πŸ™ thanks alot
Avatar
@Polar bear It looks like it dosnt even redirect to 404 page
Avatar
Dwarf Hotot
for this to happen you have to create a notfound page also then only it will show 404 page not found
there is no app/not-found.tsx page is created, thats why 404 or page not found is coming , first you have to create this file then this file will handle all the routes which are not present and show 404 or any thing which you erite in this file
Image
Avatar
@gin try this typescript router.refresh() router.push(`/board/${data.id}`);
Avatar
Polar bearOP
just tried and not working :/
Avatar
@Polar bear just tried and not working :/
Avatar
u put it in your onSuccess callback correct?
cause i had same issues in the past and this always fixed it for me
Avatar
Dwarf Hotot
You need to create not-found.tsx file in app folder
Avatar
@Alfonsus Ardani I see, then we will look at it together and which part doesn't work
Avatar
Polar bearOP
https://github.com/SHOOTSTV/trello-clone just pushed the code with the board route and page πŸ˜ƒ
(still no redirection)
Avatar
@Dwarf Hotot for this to happen you have to create a notfound page also then only it will show 404 page not found
Avatar
Polar bearOP
Oh didnt know that, on the tutorial it dosn't look like he created one, it was the default next 404 pageπŸ€”
Avatar
@gin u put it in your onSuccess callback correct?
Avatar
Polar bearOP
like this? i tried and it didnt worked
Image
no redirection?
Avatar
Polar bearOP
no :/
Avatar
and your toast triggers?
and whatever that is closes?
Avatar
Polar bearOP
thats weird cause when i hover the board i can see this on the bottom left corner
Image
but clicking dosnt do anything
Avatar
@gin and your toast triggers?
Avatar
Polar bearOP
the toaster is working yes
Image
Avatar
extremely weird
it doesnt redirect
even with refreshing the router cache
it should tho so idk
Avatar
Polar bearOP
More context
Image
looks like it auto redirects me on the last page
we can see the url changing from the good one (board/*) to the original org/** page
Avatar
@Dwarf Hotot You need to create not-found.tsx file in app folder
Avatar
Polar bearOP
i created the route instead and still not working :/
Avatar
@Polar bear More context
Avatar
did you already have file on board/?
Avatar
Polar bearOP
Yes I created one
Image
Avatar
try removing middleware.ts
and redirecting again
Avatar
Polar bearOP
i just did, it looks like i can access the board page whitout getting rollback like the video I sent
but i dont know if its just because the auth is now broken due to the middleware deletion and i can't go into the org page
Avatar
Polar bearOP
I see
that's strange because I was following a tutorial, maybe alot changed between my et his next versions?
because for example he's using authMiddleware which is deprecated and is now clerkMiddleware
Avatar
Polar bearOP
Welp update : one good one bad news, the good one is that my problem is now fixed! the bad one is that I just downgraded clerk version so i don't know what were the problem πŸ˜‚