Astro: only generate route in dev mode #486
-
Hi there! I'm using keystatic to manage my content, but only locally. But when building the app, the /keystatic route is still accessible even if useless. So I'm wondering if there's a way to keep it in dev mode only. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
I haven't tried this, but wondering if you could use Astro.redirect to redirect to the homepage when // src/pages/keystatic/[...params].astro
---
import { Keystatic } from '../../../keystatic.page'
export const prerender = false
+ if (import.meta.env.MODE === 'production') return Astro.redirect('/')
---
<Keystatic client:only /> Disabling access to Keystatic in prod is definitely a valid idea — I have heard a few other request it (or simply worry about the concept of folks accessing admin routes in production). |
Beta Was this translation helpful? Give feedback.
I haven't tried this, but wondering if you could use Astro.redirect to redirect to the homepage when
import.meta.env.MODE
is set toproduction
?Disabling access to Keystatic in prod is definitely a valid idea — I have heard a few other request it (or simply worry about the concept of folks accessing admin routes in production).