Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我用nginx配置了一个二级路径,/docs路径就没有办法访问了 #20

Open
DAAworld opened this issue Oct 9, 2023 · 7 comments

Comments

@DAAworld
Copy link

DAAworld commented Oct 9, 2023

worker_processes 1;

events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name tttt;

    location /eng/ {
        proxy_pass http://localhost:8800/;
    }
}

}
nginx路径配置如下,访问tttt/eng/docs时会报错,
Errors
Hide

Fetch errorresponse status is 404 /openapi.json

image

@DAAworld
Copy link
Author

DAAworld commented Oct 9, 2023

我还配置了app.config["APPLICATION_ROOT"] = "/eng/",其他接口都可以使用,只有/docs接口没有办法用

@DAAworld
Copy link
Author

经过测试,问题出现在 这行return render_template(ui_file, spec_url=self.openapi_url),改成return render_template(ui_file, spec_url=“eng" + self.openapi_url)这样就是可以的
@siwa_bp.route(self.doc_url)
def doc_html():
siwa_user = self.app.config.get("SIWA_USER")
siwa_pass = self.app.config.get("SIWA_PASSWORD")
if siwa_user and siwa_pass:
global users
users = {
siwa_user: generate_password_hash(siwa_pass),
}
login_info = auth.get_auth()
password = auth.get_auth_password(login_info)
status = None
user = auth.authenticate(login_info, password)
if user in (False, None):
status = 401
elif not auth.authorize(None, user, auth):
status = 403
if status:
try:
return auth.auth_error_callback(status)
except TypeError:
return auth.auth_error_callback()
ui = request.args.get("ui") or self.ui
assert ui in SUPPORTED_UI, f"ui only support with {SUPPORTED_UI}"
ui_file = f'{ui}.html'
return render_template(ui_file, spec_url=self.openapi_url)

@lzjun567
Copy link
Owner

这个 /eng 是你的业务路径吧,不能把业务代码侵入到框架代码中去

@DAAworld
Copy link
Author

这个 /eng 是你的业务路径吧,不能把业务代码侵入到框架代码中去

是的,那是我的业务路径,不知道有什么方法可以配置?

@verydemo
Copy link

verydemo commented Dec 5, 2023

这个 /eng 是你的业务路径吧,不能把业务代码侵入到框架代码中去

应该默认获取同级路由, 不应该自己去配置

@verydemo
Copy link

verydemo commented Dec 5, 2023

@lzjun567 大佬,改一下templates, 从js 那边获取当前页面的url

1 similar comment
@verydemo
Copy link

verydemo commented Dec 5, 2023

@lzjun567 大佬,改一下templates, 从js 那边获取当前页面的url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants