Can't get token from URL
Answered
Western thatching ant posted this in #help-forum
Western thatching antOP
localhost:3000/auth/1234
In my app/auth/[token]/page.tsx
export default function Page({ params }: { params: { token: string } }) {
return <div>My Post: {params.token}</div>;
}
Result -> params.token = 1234.
localhost:3000/auth/1234?code=123
The auth callback appends ?code=123.... to the URL
The '?' is messing up my ability to get the code. Anyone familiar with this?
In my app/auth/[token]/page.tsx
export default function Page({ params }: { params: { token: string } }) {
return <div>My Post: {params.token}</div>;
}
Result -> params.token = 1234.
localhost:3000/auth/1234?code=123
The auth callback appends ?code=123.... to the URL
The '?' is messing up my ability to get the code. Anyone familiar with this?
Answered by Ray
export default function Page({
params,
searchParams,
}: {
params: { slug: string }
searchParams: { [key: string]: string | string[] | undefined }
}) {
return <h1>{searchParams.code}</h1>
}2 Replies
@Western thatching ant localhost:3000/auth/1234
In my app/auth/[token]/page.tsx
export default function Page({ params }: { params: { token: string } }) {
return <div>My Post: {params.token}</div>;
}
Result -> params.token = 1234.
localhost:3000/auth/1234?code=123
The auth callback appends ?code=123.... to the URL
The '?' is messing up my ability to get the code. Anyone familiar with this?
export default function Page({
params,
searchParams,
}: {
params: { slug: string }
searchParams: { [key: string]: string | string[] | undefined }
}) {
return <h1>{searchParams.code}</h1>
}Answer
Western thatching antOP
Boss!