79481218

Date: 2025-03-03 14:33:49
Score: 0.5
Natty:
Report link

In AWS Amplify, open your app and navigate to the Build Settings section from the left-hand sidebar. Locate the amplify.yml file and manually update it to include your environment variables in the following format:

amplify.yml should look like something similar

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci --cache .npm --prefer-offline
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - .next/cache/**/*
      - .npm/**/*
env:
  variables:
    # Env
    NODE_ENV: "production"
    NAME_OF_VARIABLE_YOU_USE_ON_NEXT: ${NAME_OF_VARIABLE_YOU_SAVED_ON_AMPLIFY}
    

In your use case you would do something like this:

env:
  variables:
    # Env
    API_KEY: ${API_KEY}[![enter image description here][1]][1]

and then in your next application:

your_api_key = process.env.API_KEY
Reasons:
  • Blacklisted phrase (1): enter image description here
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Enrico