您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Angular或Angular 6中的跨源资源共享(CORS)。在具有不同端口的localhost上进行跨域调用时出现问题

Angular或Angular 6中的跨源资源共享(CORS)。在具有不同端口的localhost上进行跨域调用时出现问题

解决以上问题

首先,您需要为端口4200共享Spring引导资源。使用要共享的资源的 注释类或方法

您必须在角度应用程序中配置代理。因此,在有角度的根应用程序中创建一个proxy.json文件内容在下面

{

“/api/*”: { “target”: “http://localhost:8080", “secure”: “false”, “logLevel”: “debug”, “changeOrigin”: true }

}

building modules 3/3 modules 0 active[HPM] Proxy created: /api ->

http://localhost:8080 Subscribed to http-proxy events: [ ‘error’, ‘close’ ]

其他 2022/1/1 18:19:30 有484人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶