# Angular 启动候出现跨域无法调试的问题

**URL:** <https://www.isharkfly.com/t/angular/13906>\
**Category:** 前端\
**Created:** [March 14, 2022, 1:44pm UTC](https://www.isharkfly.com/t/angular/13906 "2022-03-14T13:44:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [March 14, 2022, 1:44pm UTC](https://www.isharkfly.com/t/angular/13906/1 "2022-03-14T13:44:38Z")

</div>

Angular 启动后访问服务器，出现了非常明确的跨域问题。

跨域问题的浏览器截图如下：  
 ![CORS](https://www.isharkfly.com/images/transparent.png)

## 解决办法

CORS 问题通常涉及到非常多的地方。

这个错误我们是通过添加启动参数来解决的。

将服务器的启动命令添加一个 `http-server ./ --cors` --cors 启动参数。

![2022-03-14_09-30-24](https://www.isharkfly.com/images/transparent.png)

在上面的图片中，我们可以看到服务器的 CORS 为 true 了。

通过这个参数解决了我们的跨域本地调试问题。
