question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Runtime env not being set

See original GitHub issue

@sls-next/serverless-component@1.19.0-alpha.45

I currently have a setup that has this nextJS setup for the frontend. But I am using a proxy on the /api route that proxies through to another external lambda JSON api (Which is up and running, and accessible)

https://github.com/chimurai/http-proxy-middleware

The issue I currently have is that on pages where I am making use of the proxied external api through getServerSideProps I am getting a The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. error.

Has anyone had a similar issue and suggestions for the correct / needed permissions? It seems like a fetch to another lambda (Accessible from my browser) is what causes the issue. Pages that dont make use of any api calls are working fine.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
jvarhocommented, May 1, 2021

@mattvb91 If you use .env files for your environment variables, Next.js build will fill them in at build time: https://nextjs.org/docs/basic-features/environment-variables

If it’s a plugin you use that requires the env vars, that might or might not work. The reference has to be detectable statically. If it does not work, there’s nothing serverless-next.js can do about it.

0reactions
mattvb91commented, May 1, 2021

@jvarho thanks! never occured to me i can of course build it into my deployment step!! thanks again

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to set an environment variable at runtime from ...
Not easily. Depends whether you want to change the process' environment, to change the value(s) returned by System.getenv() in the same JVM, ...
Read more >
Handling runtime environment variables in create-react-apps
A new package called runtime-env-cra allows you to handle environment variables in quick and easy way with create-react-apps.
Read more >
Phoenix environment variables not available at runtime - Fly.io
Sometimes the variable you think should be there/accessible (and so being set) isn't. Debugging with an echo can confirm it is.
Read more >
Environment variables in Compose | Docker Documentation
If an environment variable is not set, Compose substitutes with an empty string. In the example above, if POSTGRES_VERSION is not set, the...
Read more >
Use environment variables | Cloud Run Documentation
The environment variables defined in the container runtime contract are reserved and cannot be set. In particular, the PORT environment variable is injected ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found