I’m running into some issues I’m hoping someone can help with.
I have a background function that I am developing in a SvelteKit project that needs to have access to environment variables. When running the code in my local Dev box through netlify-cli, I am getting the following error:
✘ [ERROR] Could not resolve "$env/static/public"
1 │ ...EN, PUBLIC_S3_CLIENTSIDE_URL } from '$env/static/public';
You can mark the path "$env/static/public" as external to exclude it from the bundle, which will remove this error.
I know I can use process.env.XXX, but this background function resides in a SvelteKit project and re-uses a number of classes in that project that function just fine within non-background functions. What are people doing to get around this issue? I would hate to rewrite all code that uses SvelteKit’s $env/static/public due to this limitation.
To be clear, this is not a case of one env variable missing. This works fine if I use process.env.XXX. The problem arises when using SvelteKit’s recommended env variable support. This only affects background functions. Regular serverside functions work as expected.
I can guarantee you it has not been looked at by our developers yet since we have not yet escalated anything to them, since until today we were awaiting your response to proceed with our investigation. Now that you have responded, we’ll be happy to pick things up.
Let me know when you have, and I’ll ask the devs to take a look for us. Can’t make any promises on any timeline there (if the bug is even in our code, which may or may not be obvious to the authors), but I do promise to ask on our behalf