From 77ca3645d6dde320fc6b97a4e26d0b6e2ba17138 Mon Sep 17 00:00:00 2001
From: Heather Yu <35639529+hetd54@users.noreply.github.com>
Date: Tue, 20 Aug 2024 13:42:08 -0400
Subject: [PATCH] chore: pass host from astro
---
src/pages/api/auth.astro | 5 ++---
src/pages/api/auth.ts | 3 +--
src/pages/api/callback.astro | 2 +-
src/pages/api/callback.ts | 5 +++--
4 files changed, 7 insertions(+), 8 deletions(-)
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 {