next.js 下一个js on AWS amplify,如何设置环境变量

kdfy810k  于 2023-03-08  发布在  其他
关注(0)|答案(1)|浏览(133)

在开发过程中,一切正常,应用程序有.env.local文件,安装到amazon amplify后,应用程序看不到变量,我在环境变量中添加了我的键和值,我也试图将它们添加到控制台中,但随后应用程序中断

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
      - EMAIL=${EMAIL}
           - EMAIL_PASS=${EMAIL_PASS}
           - NEXT_PUBLIC_GOOGLE_ANALYTICS=${NEXT_PUBLIC_GOOGLE_ANALYTICS}
        - npm run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
carvr3hs

carvr3hs1#

这是用来组织yml文件的documentation,如你所见,env在顶部,后面是variables

version: 1
env:
  variables:
    key: value
backend:
  phases:
    preBuild:
      commands:
        - *enter command*
    build:
      commands:
        - *enter command*
    postBuild:
        commands:
        - *enter command*
frontend:
  phases:
    preBuild:
      commands:
        - cd react-app
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    files:
        - location
        - location
    discard-paths: yes
    baseDirectory: location
  cache:
    paths:
        - path
        - path
test:
  phases:
    preTest:
      commands:
        - *enter command*
    test:
      commands:
        - *enter command*
    postTest:
      commands:
        - *enter command*
  artifacts:
    files:
        - location
        - location
    configFilePath: *location*
    baseDirectory: *location*

相关问题