Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,33 @@ import 'katex/dist/katex.min.css'
import 'highlight.js/styles/atom-one-dark.css'
---

<script>
async function checkCurrentAuth() {
const password = localStorage.getItem('pass')
if(!password) {
window.location.href = '/password'
return
}
const response = await fetch('/api/auth', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
pass: password,
}),
})
const responseJson = await response.json()
if (responseJson.code !== 0)
window.location.href = '/password'
}
checkCurrentAuth()
</script>

<Layout title="ChatGPT API Demo">
<main >
<Header />
<Generator client:load />
<Footer />
</main>
</Layout>

<script>
async function checkCurrentAuth() {
const password = localStorage.getItem('pass')
const response = await fetch('/api/auth', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
pass: password,
}),
})
const responseJson = await response.json()
if (responseJson.code !== 0)
window.location.href = '/password'
}
checkCurrentAuth()
</script>