Capítulo 247 de 456
Experimental config that enables React's tainting APIs, letting you mark objects or values as forbidden from crossing the Server-Client boundary, an extra defensive layer against accidentally leaking sensitive data to Client Components.
experimental.taint: boolean flag; enabling it also switches the app directory to the React experimental channel.experimental_taintObjectReference: taints an object reference so passing the whole object to a Client Component throws.experimental_taintUniqueValue: taints a specific primitive value (e.g. an API key) tracked by reference/lifetime, not by the variable holding it.import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
taint: true,
},
}
export default nextConfig
import { experimental_taintUniqueValue } from 'react'
async function getSystemConfig(): Promise<SystemConfig> {
const config = await configService.getConfigDetails()
experimental_taintUniqueValue(
'Do not pass configuration tokens to the client',
config,
config.SERVICE_API_KEY
)
return config
}
version::${apiKey} não é bloqueado, pois tainting não propaga para valores derivados.taint também ativa o canal experimental do React para app.taintObjectReference protege o objeto inteiro; taintUniqueValue protege um campo/valor específico.