update
This commit is contained in:
@@ -1,12 +1,24 @@
|
||||
// import { parse } from 'cookie'
|
||||
import { parse } from 'cookie'
|
||||
|
||||
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 issuerUrl = new URL('/authorize', context.cloudflare.env.ISSUER_URL)
|
||||
issuerUrl.search = url.search
|
||||
|
||||
if (!cookies.session_id) {
|
||||
url.pathname = '/'
|
||||
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: {
|
||||
Location: url.toString()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
const r = await fetch(issuerUrl.toString(), {
|
||||
method: 'GET',
|
||||
|
||||
Reference in New Issue
Block a user