diff --git a/src/pages/api/auth.astro b/src/pages/api/auth.astro index a6175a6..63ead9d 100644 --- a/src/pages/api/auth.astro +++ b/src/pages/api/auth.astro @@ -2,8 +2,7 @@ import Layout from "../../layouts/Layout.astro" import { GET } from "./auth" -const auth = await GET() +const auth = await GET(Astro.url.origin) --- - - + diff --git a/src/pages/api/auth.ts b/src/pages/api/auth.ts index e1ad1cb..c124505 100644 --- a/src/pages/api/auth.ts +++ b/src/pages/api/auth.ts @@ -3,9 +3,8 @@ import { create } from "../../../api/_lib/oauth2.ts" export const prerender = false -export const GET = () => { +export const GET = (host: string) => { const randomString = () => crypto.randomBytes(4).toString(`hex`) - const host = "https://mmp-site-b1c9b.web.app" const oauth2 = create() const url = oauth2.authorizationCode.authorizeURL({ diff --git a/src/pages/api/callback.astro b/src/pages/api/callback.astro index 8b6f0d2..bfaf901 100644 --- a/src/pages/api/callback.astro +++ b/src/pages/api/callback.astro @@ -2,7 +2,7 @@ import Layout from "../../layouts/Layout.astro" import { GetCallback } from "./callback" -const callback = GetCallback(Astro.request) +const callback = GetCallback(Astro.request, Astro.url.origin) --- diff --git a/src/pages/api/callback.ts b/src/pages/api/callback.ts index 5213ac3..bc986e1 100644 --- a/src/pages/api/callback.ts +++ b/src/pages/api/callback.ts @@ -1,9 +1,10 @@ import { create, renderBody } from "../../../api/_lib/oauth2.ts" -export const GetCallback = async (req: Request) => { +export const prerender = false + +export const GetCallback = async (req: Request, host: string) => { const params = new URLSearchParams(req.url) const code = params.get("code") || "" - const host = "https://mmp-site-b1c9b.web.app" const oauth2 = create() try {