从来源'http:// localhost:4200'到'http:// [:: 1]:3000 / api / requests /…'的XMLHttpRequest访问已被CORS策略阻止

问题描述 投票:0回答:1
我有一个项目:

    后端使用环回4。
  • 前端使用Angular。
  • 大约3天前,它运行良好。但是现在它可以工作了。这是错误图像:enter image description here

    我尝试在服务器上进行cros设置:

    export async function main(options: ApplicationConfig = { rest: { cors: { origin: '*', methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', preflightContinue: false, optionsSuccessStatus: 204, maxAge: 86400, credentials: true, }, }, }) { const app = new ApartmentManagementApplication(options); ... }

    但仍无法正常工作,请帮助我修复它。    
  • angular loopback loopback4
    1个回答
    0
    投票
    我对回送没有太多了解,但我会使用可通过NPM(https://www.npmjs.com/package/cors)获得的CORS包在Node.js中解决此问题。因此,找到类似的解决方案。
    © www.soinside.com 2019 - 2024. All rights reserved.