在我的Gatsby V2网络应用中,我正在使用Firebase身份验证登录google。它可以在MacBook Pro上正常运行,但是当我部署到Firebase Hosting时无法正常工作。请在随附的屏幕截图中查看控制台日志。
我已经检查了Firebase管理面板中是否允许localhost和google登录的已部署站点使用正确的URL。我的猜测是,它与gatsby-plugin-manifest或gatsby-plugin-offline有关。按照https://firebase.google.com/docs/hosting/reserved-urls,我以以下方式为gatsby-plugin-offline添加了白名单URL,同时保留了现有的白名单URL(按照https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-offline):-
{
resolve: `gatsby-plugin-offline`,
options: {
navigateFallbackWhitelist: [/^[^?]*([^.?]{5}|\.html)(\?.*)?$/, /^(?!\/__).*/]
}
}
我再次部署了该站点,但是仍然无法正常工作。
复制步骤
在Firebase Hosting上部署一个利用Firebase Google Auth的GatsbyJS网站。使用了以下插件:-
plugins: [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-shopify`,
options: {
shopName: `...`,
accessToken: `...`,
verbose: true,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/pages`,
name: 'pages',
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/asset/img`,
name: `images`,
}
},
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/asset/font`,
name: `fonts`,
}
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name: '...',
short_name: '...,
start_url: '/',
background_color: '#f2efec',
theme_color: '#f2efec',
display: 'minimal-ui',
icon: '...'
}
},
{
resolve: `gatsby-plugin-offline`,
options: {
navigateFallbackWhitelist: [/^[^?]*([^.?]{5}|\.html)(\?.*)?$/, /^(?!\/__).*/]
}
},
`gatsby-plugin-netlify-cms`,
`gatsby-plugin-netlify`,
]
预期结果-单击Google登录按钮后,弹出窗口将打开,要求提供Google凭据。
实际结果-谷歌登录弹出窗口保持空白然后关闭(上面显示控制台错误)