開発環境(HMR)と本番環境(AdSense)の両方に対応した、src/proxy.ts の最終設定がこちらです:
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 ? "ws://localhost:* ws://127.0.0.1:*" : ,
]
.()
.();
csp = [
,
,
,
,
,
,
,
].();