1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

reCAPTCHAを使用しようとしたらCSP設定で引っかかった

Posted at

背景

  • firebaseのnew RecaptchaVerifierを使ってreCAPTCHのインスタンスと生成
  • render()でトークンを更新 ←エラーが出た
Refused to load the script '<https://www.google.com/recaptcha/api.js...>' because it violates the following Content Security Policy directive: xxx. Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

エラーの理由

コンテンツセキュリティポリシー(CSP)に従わないscriptを読み込もうとしているため、'https://www.google.com/recaptcha/api.js...'
は読み込めない

解決策

headerの'Content-Security-Policy'に以下を追加する

"script-src 'self' www.google.com/recaptcha/api.js www.gstatic.com "

終わりに

reCAPTCHAが使えなくてあっせった。。
https://nextjs.org/docs/pages/building-your-application/configuring/content-security-policy

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?