You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

FastAPI部署至AWS后Auth0回调URL不匹配问题求助

部署AWS后FastAPI集成Auth0出现重定向错误

我用Python FastAPI(搭配Jinja Templates)开发Web应用,集成Auth0实现用户认证,部署在AWS Lambda、API Gateway和Route53上。本地运行完全正常,但部署后访问时触发了Auth0重定向错误:

Auth0重定向错误

我已经在Auth0应用的Callback URIs配置项里添加了本地可用地址http://localhost:8000/callback,尝试添加Route53对应的地址https://route.dev.zone.com/callback,但问题依旧。

有没有人碰到过这种本地正常、部署到AWS后Auth0重定向失败的情况?

补充:我觉得大概率不是代码问题,但还是附上相关登录逻辑代码:

oauth = OAuth()
oauth.register(
    name='auth0',
    client_id=auth0.get("AUTH0_CLIENT_ID"),
    client_secret=auth0.get("AUTH0_CLIENT_SECRET"),
    server_metadata_url=f'https://{auth0.get("AUTH0_DOMAIN")}/.well-known/openid-configuration',
    client_kwargs={'scope': 'openid profile email'}
)
@app.get('/login')
async def login(request: Request):
    auth0 = oauth.create_client('auth0')
    redirect_uri = request.url_for('callback')
    return await auth0.authorize_redirect(request, redirect_uri)
@app.get('/callback')
async def callback(request: Request):
    auth0 = oauth.create_client('auth0')
    token = await auth0.authorize_access_token(request)
    request.session['userinfo'] = token.get('userinfo')
    return RedirectResponse("/")

内容的提问来源于stack exchange,提问作者frenchytheasian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 19:42:34