Nuxt

nuxt/public-runtime-config

Secrets live in the top level of runtimeConfig, never under runtimeConfig.public, which every page sends to the browser.

poważnastatycznefe-nuxt

Dlaczego

Everything under runtimeConfig.public is serialised into the payload of every page, readable in the page source by anyone. A secret, a password or a private key placed there is published, and rotating it after the fact is the only fix.

Poprawka

Move the value to the top level of runtimeConfig (server-only) and read it in server/ routes with useRuntimeConfig(event). Call third-party APIs that need it from a server route, not from the browser. Keep in public only values meant to be public: the API base URL, a site key, a publishable key.

Przykłady

// bad
runtimeConfig: { public: { stripeSecretKey: '' } }
// good
runtimeConfig: { stripeSecretKey: '', public: { stripePublishableKey: '' } }

Źródła

Fakty

Identyfikator
nuxt/public-runtime-config
Waga
poważna
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
project
Tylko w projektach z
nuxt
Uczy jej skill
fe-nuxt Nuxt apps
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain nuxt/public-runtime-config