Skip to content

Astro: only generate route in dev mode #486

Discussion options

You must be logged in to vote

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 to production?

// 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).

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@florian-lefebvre
Comment options

@simonswiss
Comment options

@needim
Comment options

@florian-lefebvre
Comment options

@needim
Comment options

Answer selected by florian-lefebvre
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants