Security · Nuxt
I found an API key in my page source in Nuxt
The fix for Nuxt
13x detects your framework from the response and hands you this version rather than the generic one — below 50% confidence it hedges and gives you the generic one instead.
Rotate the key first — revoke and reissue it before changing code.
Nuxt splits this explicitly: everything under runtimeConfig is server-only,
and only runtimeConfig.public is exposed to the browser.
// nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
stripeSecretKey: process.env.STRIPE_SECRET_KEY, // server only
public: {
stripePublishableKey: process.env.STRIPE_PUBLISHABLE_KEY,
},
},
});Read the secret inside server/ only:
// server/api/checkout.post.ts
export default defineEventHandler(async (event) => {
const { stripeSecretKey } = useRuntimeConfig(event);
// …
});Calling useRuntimeConfig() in a component gives you the public block only,
which is what you want.
On a different stack? The general version of this fix explains what 13x checks and why it matters, without assuming a framework.
Check your Nuxt site
113 deterministic checks against your live URL, in about 30 seconds. Framework detected from the response, so every fix comes back in the form your stack actually uses.
No signup. Results in 30 seconds.