已部署网站上的 Auth0 登录(和重定向)问题

问题描述 投票:0回答:3

我遇到了 Auth0 登录问题。我的本地项目一切正常(日志记录、重定向到主页)。将这个网站部署到github.io后出现了一些问题。

当我使用 Auth0 时,我必须在 Auth0 项目仪表板中定义允许的回调 URL。 对于本地项目,我在此文本框中写入 http://localhost:3000 ,一切都很好。 对于部署在 Github Pages 上的项目,我写了 https://michalgornicki.github.io/cats/,单击登录按钮后出现此错误:

Error when I paste my website address (https://michalgornicki.github.io/cats/) to allowed callbacks.

在允许的回调 URL 中写入 https://michalgornicki.github.io 后,单击登录按钮会重定向到 https://michalgornicki.github.io 链接,其中包含信息“此处没有 GitHub Pages 站点。”

如何解决这个问题?

authentication redirect callback auth0
3个回答
1
投票

我想我找到了这个问题的根源。在redirectUri = {“}中的Index.js文件中,我有“window.location.origin”,它适用于本地项目,但链接到部署项目上的https://michalgornicki.github.io。如果我将我的网站链接粘贴到redirectUri 现在运行良好。


0
投票

这确实有效。还要记住在注销按钮代码中添加相同的链接,否则当用户注销时页面将中断。

<button onClick={() => logout({ logoutParams: { returnTo: "https://username.github.io/your-app" } })}>

0
投票

我有同样的问题,但这个解决方案对我不起作用。你能检查一下我做错了什么吗?

我的应用程序页面:https://katerynahutyryak.github.io/Forkify-client/

Auth0 设置中允许的回调 URL:https://katerynahutyryak.github.io

我的配置代码:

const controlAuthentication = async () => {
    auth0Client = await createAuth0Client({
        domain: '********',
        clientId: '*********',
        authorizationParams: {
            audience: 'https://forkify-fvelk.ondigitalocean.app/api/v1',
            redirect_uri: 'https://katerynahutyryak.github.io/Forkify-client/',
        },
        useRefreshTokens: true,
        cacheLocation: 'localstorage',
    })
© www.soinside.com 2019 - 2024. All rights reserved.