-
+
@@ -69,7 +69,7 @@
const route = useRoute()
- if(route.params.files == 'scores') {
+ if(process.client && route.params.files == 'scores') {
const { data: works } = await useFetch('/api/works', {
transform: (works) => {
return works.find(w => w.score === route.params.filename)
diff --git a/nuxt.config.ts b/nuxt.config.ts
index de034bc..4c70fb2 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -1,5 +1,8 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
+ runtimeConfig: {
+ adminPassword: process.env.PASSWORD
+ },
modules: ['@nuxtjs/tailwindcss', '@nuxt/image', '@nuxt/icon', '@pinia/nuxt', 'nuxt-headlessui', 'nuxt-swiper', 'nuxt-umami'],
image: {
domains: ['unboundedpress.org']
diff --git a/pages/admin.vue b/pages/admin.vue
index 969cb2b..7d45f1d 100644
--- a/pages/admin.vue
+++ b/pages/admin.vue
@@ -204,12 +204,21 @@ const fileFolders = [
{ key: 'hdp_images', label: 'HDP Images' }
]
-function checkPassword(data) {
- if (data.password === 'admin123') {
- authenticated.value = true
- loadItems()
- } else {
- alert('Incorrect password')
+async function checkPassword(data) {
+ try {
+ const result = await $fetch('/api/auth/verify-password', {
+ method: 'POST',
+ body: { password: data.password }
+ })
+ if (result.valid) {
+ authenticated.value = true
+ loadItems()
+ } else {
+ alert('Incorrect password')
+ }
+ } catch (e) {
+ console.error('Password check failed:', e)
+ alert('Error: ' + e.message)
}
}
diff --git a/server/api/auth/verify-password.post.ts b/server/api/auth/verify-password.post.ts
new file mode 100644
index 0000000..8c7ebcf
--- /dev/null
+++ b/server/api/auth/verify-password.post.ts
@@ -0,0 +1,10 @@
+export default defineEventHandler(async (event) => {
+ const config = useRuntimeConfig()
+ const body = await readBody(event)
+
+ if (body.password === config.adminPassword) {
+ return { valid: true }
+ }
+
+ return { valid: false }
+})