Skip to content

how to get environment variables within a server route using cloudflare? #1100

Answered by brandonroberts
stewones asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you should be able to get it from the event context

export const load = async ({
  params, // params/queryParams from the request
  req, // H3 Request
  res, // H3 Response handler
  fetch, // internal fetch for direct API calls,
  event, // <---- Full H3 Event
}: PageServerLoad) => {
 console.log(event.context['cf'])
  return { isProduction };
};

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stewones
Comment options

Answer selected by stewones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants