Uylin
发布于 2023-09-07 / 30 阅读 / 0 评论 / 0 点赞

sub_filter

Nginx Sub_filter

问题

将Springboot利用部署到服务器上 通过域名拜访swagger-ui(通过了Nginx代理) 进行前后端联调 然而理论点击执行的时候 提醒: TypeError: Failed to fetch

如 swagger-ui拜访地址是

    https://foo.com/test/api/insurance/swagger-ui/index.html

点击执行 调用后端接口的地址 变成了

    http://foo.com:80/solvStaInfos

理论后端地址应该是

    https://foo.com/test/api/insurance/solvStaInfos

解决

Nginx动静批改接口返回内容

    location /test/api/insurance/v3/api-docs {
        sub_filter 'http://foo.com:80' 'https://foo.com/test/api/insurance/';
        sub_filter_types application/json;
        proxy_pass ...;
    }