add
This commit is contained in:
@@ -5,16 +5,16 @@ import type { Route } from './+types/authorize'
|
||||
export async function loader({ request, context }: Route.LoaderArgs) {
|
||||
const cookies = parse(request.headers.get('Cookie') || '')
|
||||
const url = new URL(request.url)
|
||||
const redirect = new URL('/', url.origin)
|
||||
const issuerUrl = new URL('/authorize', context.cloudflare.env.ISSUER_URL)
|
||||
issuerUrl.search = url.search
|
||||
redirect.search = url.search
|
||||
|
||||
if (!cookies.session_id) {
|
||||
url.pathname = '/'
|
||||
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: {
|
||||
Location: url.toString()
|
||||
Location: redirect.toString()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -29,6 +29,15 @@ export async function loader({ request, context }: Route.LoaderArgs) {
|
||||
redirect: 'manual'
|
||||
})
|
||||
|
||||
if (!r.ok) {
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: {
|
||||
Location: redirect.toString()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return new Response(await r.text(), {
|
||||
status: r.status,
|
||||
headers: r.headers
|
||||
|
||||
Reference in New Issue
Block a user