且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何修复 Angular 5 中的 CORS 问题 http 请求

更新时间:2023-08-18 17:18:40

CORS 是浏览器使用的一种工具,用于防止一个源(在您的情况下为 localhost)访问来自另一个(example.com)的资源,而服务器没有明确告诉您可以通过 CORS 标头(如 Access-Control-Allow-Origin 等)访问它.

CORS is a tool employed by browsers to prevent one origin (localhost in your case) from accessing resources from another (example.com) without the server explicitly saying you can access it via CORS headers like Access-Control-Allow-Origin and others.

服务器需要提供这些标头以便您访问其资源.

It is the server that needs to provide those headers in order for you to access it's resources.

Mozilla 对此有很好的描述这里.

Mozilla has a good write up on it here.