Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
chore: pass host from astro
Browse files Browse the repository at this point in the history
  • Loading branch information
hetd54 committed Aug 20, 2024
1 parent 43f81e2 commit 77ca364
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/pages/api/auth.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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)
---

<Layout title="Authenticate" description="">
</Layout>
<Layout title="Authenticate" description="" />
3 changes: 1 addition & 2 deletions src/pages/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/callback.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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)
---

<Layout title="Callback" description="" />
5 changes: 3 additions & 2 deletions src/pages/api/callback.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 77ca364

Please sign in to comment.