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

Commit

Permalink
fix: script tags for accessing window on client for astro
Browse files Browse the repository at this point in the history
  • Loading branch information
hetd54 committed Aug 26, 2024
1 parent ae18038 commit cc272aa
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/pages/api/auth.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ import Layout from "../../layouts/Layout.astro"
import { GET } from "./auth"
const auth = await GET(Astro.url.origin)
const receiveMessage = (message: MessageEvent) => {
window.opener.postMessage(
"authorization:github:${status}:${JSON.stringify(content)}",
message.origin
)
window.removeEventListener("message", receiveMessage, false)
}
window.addEventListener("message", receiveMessage, false)
window.opener.postMessage("authorizing:github", "*")
---

<Layout title="Authenticate" description="" />

<script>
const receiveMessage = (message: MessageEvent) => {
window.opener.postMessage(
"authorization:github:${status}:${JSON.stringify(content)}",
message.origin
)
window.removeEventListener("message", receiveMessage, false)
}
window.addEventListener("message", receiveMessage, false)

window.opener.postMessage("authorizing:github", "*")
</script>

0 comments on commit cc272aa

Please sign in to comment.