启动后端后,前端访问不到后端
报跨域问题,拒接连接
于是用swagger测试后端接口
报如下错误
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sun Mar 06 16:22:48 CST 2022
There was an unexpected error (type=Not Found, status=404).
No message available
这是我的nginx配置
server {
listen 9001;
server_name localhost;
location / {
proxy_pass https://www.baidu.com;
}
location ~/eduservice/ {
proxy_pass http://localhost:8001;
}
location ~/eduoss/ {
proxy_pass http://localhost:8002;
}
}
访问8001端口,结果正常
单独访问9001也能跳转百度
但是访问http://localhost:9001/eduservice/swagger-ui.html则显示如上错误
检查启动类和controller包位置,没有问题
controller类也加了@CrossOrigin注解
请问这是什么原因呢
你加个 ^ 试下
location ^~/eduoss/ {