I want to pass
process.env.PAYLOAD_PUBLIC_NON_SENSITIVE_KEY
to a custom field component because
process.env === {}
on the admin panel.
I've tried to convert my collection file to
.tsx
but cannot pass an instantiated component directly
Anyone know if I can pass my own props to this component? Or some other way to access
process.env.PAYLOAD_PUBLIC_NON_SENSITIVE_KEY
?
Ended up just hardcoding the non-sensitive key as an
export const ...
instead of trying to use it through
process.env
Hey @allannnc apologies for not getting back to you sooner but we're glad you found a solution!
@allannnc you should be able to access envs prefixed with PAYLOAD_PUBLIC. Are you setting up dotenv in your payload config and server file?
Hey @jarrod_not_jared, my
server.ts
looks like
import cookieParser from 'cookie-parser';
import cors from 'cors';
import dotenv from 'dotenv';
import express from 'express';
import payload from 'payload';
dotenv.config();
// ...internal imports
// ...rest of file
and my
payload.config.ts
looks very similar
import path from 'path';
// ...external lib imports e.g. from 'payload'
dotenv.config();
// ...internal imports
// ...rest of file
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.