Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Environment variables inside custom components undefined

default discord avatar
vstarush2 years ago
1 1

Hello,

I found that when I add a custom component like this inside a collection:

...
fields: [
        {
            name: "approveButton",
            label: " ",
            type: "ui",
            admin: {
                components: {
                    Field: ApproveButtonComponent,
                }
            }
        },
]
...

inside the "ApproveButtonComponent" environment variables are not available.
Is there a way to share environment variables to custom components like this?

Thanks in advance for your help!

  • Selected Answer
    default discord avatar
    r1tsuu2 years ago

    are you using 2.0 or 3.0?
    if 2.0 public envs that should be accessible from the front end need to start with the prefix PAYLOAD_PUBLIC like PAYLOAD_PUBLIC_URL
    3.0 - the same but NEXT_PUBLIC.

    1 reply
  • default discord avatar
    vstarush2 years ago

    Thank you so much @r1tsuu ! This worked like a charm :)

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.