首页 > 解决方案 > 是否允许将表单操作设置为在内容安全策略中包含 *.localhost:3000?

问题描述

我收到此错误:

Refused to send form data to 'http://example-subdomain.localhost:3000/'
because it violates the following Content Security Policy directive:
"form-action 'self' *.example.co *.localhost:3000".

所以很简单,我想从登台服务器(example-staging.com)重定向到本地机器(http://example-subdomain.localhost:3000/)。当我localhost:4000用于我的后端应用程序时,它工作得很好,所以重定向localhost:4000http://example-subdomain.localhost:3000/.

因此,为了澄清什么是什么:

http://example-subdomain.localhost:3000/- 本地机器上的前端应用程序

example-staging.com- 登台服务器,后端 api

localhost:4000- 本地机器上的后端应用程序

标签: content-security-policy

解决方案


我只在 Chrome 中测试了这个东西。它在 Firefox 中运行良好。看起来像 Chrome 浏览器中的错误。我要报告它。


推荐阅读