IGeekFan.AspNetCore.Knife4jUI icon indicating copy to clipboard operation
IGeekFan.AspNetCore.Knife4jUI copied to clipboard

请问如何在api地址前面自定义前缀啊,就是测试发送时的api url那里

Open christan-duplicate opened this issue 3 years ago • 3 comments
trafficstars

请问如何在api地址前面自定义前缀啊,就是测试时的api url那里

christan-duplicate avatar Dec 03 '21 17:12 christan-duplicate

如果 你要nginx 代理跑 ,然后加前缀。可以参考 其他 issues

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo { Title = "API V1", Version = "v1" });
                c.AddServer(new OpenApiServer()
                {
                    Url = "http://localhost:81/admin/",
                    Description = "vvv"
                });
        }

nginx配置

    server {
        listen       81;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        location ^~ /admin/ {
            proxy_pass http://localhost:5000/;
            proxy_redirect  off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

本来项目 http://localhost:5000/index.html#/home 就能运行跑。

现在 localhost:81/admin 也可访问。

luoyunchong avatar Dec 16 '21 15:12 luoyunchong

谢谢你的回复,其实我只想在前面加两个点: image

christan-duplicate avatar Dec 17 '21 01:12 christan-duplicate

做不了。。

luoyunchong avatar Dec 17 '21 01:12 luoyunchong