إليك الإعداد النهائي في src/proxy.ts الذي يتعامل مع كل من التطوير (HMR) والإنتاج (AdSense):
const nonce = crypto.randomUUID().replace(/-/g, "");
const isDev = process.env.NODE_ENV === "development";
const scriptSrc = [
"'self'",
`'nonce-${nonce}'`,
"'strict-dynamic'",
"https://www.googletagmanager.com",
"https://www.google-analytics.com",
"https://pagead2.googlesyndication.com",
"https://fundingchoicesmessages.google.com",
"https://tpc.googlesyndication.com",
"https://googleads.g.doubleclick.net",
isDev ? "'unsafe-eval'" : "",
]
.filter(Boolean)
.join(" ");
const connectSrc = [
"'self'",
"https://www.google-analytics.com",
"https://region1.google-analytics.com",
"https://www.googletagmanager.com",
"https://pagead2.googlesyndication.com",
"https://googleads.g.doubleclick.net",
"https://adtrafficquality.google",
"https://ep1.adtrafficquality.google",
"https://ep2.adtrafficquality.google",
"https://fundingchoicesmessages.google.com",
"https://challenges.cloudflare.com",
isDev ? : ,
]
.()
.();
csp = [
,
,
,
,
,
,
,
].();