在Swagger请求失败:Failed to fetch. Possible Reasons: CORS Network Failure URL scheme must be "http" or "https" for CORS request

技术运维Swagger 162

在swagger-ui中呈现的错误是:

只看此图大概率以为是跨域的问题或者schema中没有配置请求协议http/https引起的,但是Chrome控制台的错误提示是:

Refused to load the script 'http://xxxxx' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' 'unsafe-inline'"

认真检查了项目都没问题,最后想起来安装过几个包最后又卸载掉了,最后把node_modules全部删除用npm i重新安装,安装完后成一切正常。

太诡异了。

Post Comment