Skip to content

403 error when NEXT_IMAGE_ALLOWED_DOMAINS is declared in netlify.toml #506

Closed
@mfgredo

Description

@mfgredo

Describe the bug
Environment variable NEXT_IMAGE_ALLOWED_DOMAINS declared in netlify.toml for image handling is ignored. If it's declared in Netlify UI works fine.

image
or
image
gives a 403 error "Image is not from a permitted domain" ❌

image
no "Image is not from a permitted domain" error ✔

To Reproduce
Repository: https://github.com/Marcelo-Figueiredo/next-plugin-issue
Steps to reproduce the behavior:

  1. Create a new next app
  2. have a next/image component with src="https://randomuser.me/api/portraits/men/75.jpg"
  3. Set the NEXT_IMAGE_ALLOWED_DOMAINS = "randomuser.me" variable in netlify.toml
  4. Deploy to netlify with essential plugin (403 error)
  5. Set variables in Netlify UI
  6. Re-deploy (no 403 error)

Expected behavior
There should be no error if NEXT_IMAGE_ALLOWED_DOMAINS is declared in netlify.toml

Versions

  • Next.js: 10.0.6

If you're using file-based installation

  • netlify.toml:
[build]
  command = "yarn build"
  publish = "out"

[build.environment]
  NEXT_IMAGE_ALLOWED_DOMAINS = "randomuser.me"
  FORCE_WEBP_OUTPUT = "true"
  NODE_VERSION = "12.18.2"
  YARN_VERSION = "1.19.1"
  NETLIFY_USE_YARN = "true"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions