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

Amplify Hosting构建报错:auth headless缺失OAuth相关输入参数

Amplify Web App 构建错误排查:缺失第三方认证环境变量

问题描述

将前端应用部署到Amplify Web App时触发构建错误,已完成后端Google和Facebook开发密钥的认证配置,也尝试添加googleAppIdUserPool、facebookAppIdUserPool等环境变量,并用Authenticator.Provider包裹前端,但问题仍未解决。疑问点:是否和API使用API密钥(生产环境不推荐)有关?还是构建脚本或环境变量位置不正确导致的?

构建日志

# Starting phase: build
2023-02-28T21:11:27.145Z [INFO]: [0mAmplify AppID found: d3patqdt499898. Amplify App name is: tmtAmplifyApp[0m
2023-02-28T21:11:27.195Z [INFO]: [0mBackend environment dev found in Amplify Console app: tmtAmplifyApp[0m
2023-02-28T21:11:28.200Z [WARNING]: - Fetching updates to backend environment: dev from the cloud.
2023-02-28T21:11:29.423Z [WARNING]: - Building resource api/tmtamplifyapp
2023-02-28T21:11:29.703Z [INFO]: ⚠️ WARNING: owners may reassign ownership for the following model(s) and role(s): Booking: [owner]. If this is not intentional, you may want to apply field-level authorization rules to these fields. To read more: https://docs.amplify.aws/cli/graphql/authorization-rules/#per-user--owner-based-data-access.
2023-02-28T21:11:31.211Z [INFO]: ✅ GraphQL schema compiled successfully.
                                 Edit your schema at /codebuild/output/src269408372/src/tmtamplifyapp/amplify/backend/api/tmtamplifyapp/schema.graphql or place .graphql files in a directory at /codebuild/output/src269408372/src/tmtamplifyapp/amplify/backend/api/tmtamplifyapp/schema
2023-02-28T21:11:31.214Z [WARNING]: - Building resource auth/tmtAmplifyApp
2023-02-28T21:11:31.263Z [WARNING]: - Building resource storage/s3tmtamplifyappstoragec3cc73b4
2023-02-28T21:11:31.322Z [WARNING]: ✔ Successfully pulled backend environment dev from the cloud.
2023-02-28T21:11:31.335Z [WARNING]: ✖ There was an error initializing your environment.
2023-02-28T21:11:31.366Z [INFO]: 🛑 Could not initialize categories for 'dev': auth headless is missing the following inputParams facebookAppIdUserPool, facebookAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool
2023-02-28T21:11:31.366Z [INFO]: Resolution: Review the error message and stack trace for additional information.
                                 Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
2023-02-28T21:11:31.375Z [INFO]: Session Identifier: 29680280-992f-412f-a130-fabce1ed8550
2023-02-28T21:11:31.375Z [WARNING]: - Creating Zip
2023-02-28T21:11:31.389Z [INFO]: ✅ Report saved: /tmp/tmtAmplifyApp/report-1677618691379.zip
2023-02-28T21:11:31.389Z [INFO]: 
2023-02-28T21:11:31.389Z [WARNING]: - Sending zip
2023-02-28T21:11:31.390Z [INFO]: File at path: '/codebuild/output/src269408372/src/tmtamplifyapp/amplify/backend/amplify-meta.json' does not exist
2023-02-28T21:11:31.390Z [WARNING]: ✖ Sending zip
2023-02-28T21:11:31.408Z [ERROR]: !!! Build failed
2023-02-28T21:11:31.409Z [ERROR]: !!! Non-Zero Exit Code detected
2023-02-28T21:11:31.409Z [INFO]: # Starting environment caching...
2023-02-28T21:11:31.409Z [INFO]: # Environment caching completed

错误信息(中文翻译)

Amplify Hosting 构建错误:无法初始化'dev'环境的分类:无头认证缺失以下输入参数 facebookAppIdUserPool, facebookAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool

问题分析与解决方案

问题根源

这个错误和API使用API密钥无关,核心原因是Amplify构建过程中无法读取到第三方认证所需的完整环境变量,具体是缺少Facebook和Google的App ID及Secret参数。

解决方案步骤

  • 确认环境变量配置位置与完整性
    登录Amplify控制台,进入目标应用 → 左侧「App settings」→「Environment variables」,确保添加以下4个名称完全匹配的环境变量(大小写敏感):

    • facebookAppIdUserPool
    • facebookAppSecretUserPool
    • googleAppIdUserPool
    • googleAppSecretUserPool
      变量值需和Google、Facebook开发者平台获取的密钥完全一致。
  • 检查构建脚本的环境变量传递
    确保package.json中的build命令无需额外配置即可读取Amplify注入的环境变量,无需在前端代码中硬编码这些敏感值。

  • 同步后端配置
    如果之前通过本地Amplify CLI配置后端,需确认云端的后端环境和本地配置保持同步,避免出现认证配置不一致的情况。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.29 17:00:08