This commit is contained in:
2025-12-03 13:44:22 -03:00
parent 1b4cbbce6c
commit 967e275f29
2 changed files with 5 additions and 14 deletions

View File

@@ -12,16 +12,11 @@ export async function loader({ request, context }: Route.LoaderArgs) {
loginUrl.search = url.search loginUrl.search = url.search
if (!cookies?.SID) { if (!cookies?.SID) {
return new Response(null, { throw redirect(loginUrl.toString())
status: 302,
headers: {
Location: loginUrl.toString()
}
})
} }
if (!url.searchParams.has('client_id')) { if (!url.searchParams.has('client_id')) {
throw redirect('https://scorm.eduseg.workers.dev/') throw redirect(context.cloudflare.env.APP_URL)
} }
const r = await fetch(issuerUrl.toString(), { const r = await fetch(issuerUrl.toString(), {
@@ -34,7 +29,7 @@ export async function loader({ request, context }: Route.LoaderArgs) {
}) })
if (r.status === 302) { if (r.status === 302) {
return new Response(await r.text(), { return new Response(null, {
status: r.status, status: r.status,
headers: r.headers headers: r.headers
}) })
@@ -45,10 +40,5 @@ export async function loader({ request, context }: Route.LoaderArgs) {
throw redirect(new URL('/deny', url.origin).toString()) throw redirect(new URL('/deny', url.origin).toString())
} }
return new Response(null, { throw redirect(loginUrl.toString())
status: 302,
headers: {
Location: loginUrl.toString()
}
})
} }

View File

@@ -9,6 +9,7 @@ routes = [
mode = "smart" mode = "smart"
[vars] [vars]
APP_URL = "https://scorm.eduseg.workers.dev/"
ISSUER_URL = "https://58tkjsb308.execute-api.sa-east-1.amazonaws.com" ISSUER_URL = "https://58tkjsb308.execute-api.sa-east-1.amazonaws.com"
[observability.logs] [observability.logs]