#Using astro:env/server in shipping rates plugin fails to build
25 messages · Page 1 of 1 (latest)
@upper bison to confirm have you followed the docs exactly?
if possible, it maybe worth posting your debug.log file 🙂
Configure and use environment variables in your Wix CLI project to store configuration values and secrets outside of your code. Learn about the types of environment variables available in Wix CLI projects. In this step, you define the structure of your environment variables in astro.config.mjs, specifying each variable’s type, context (client ...
Yes, and here is the debug.log:
----- CLI crash report at 2026-03-07T11:45:01.118Z
Error Trace
Error: Command failed with exit code 1: npx --no-install astro build
at makeError (APP_PATH\node_modules\node_modules\execa\lib\error.js:60:11)
at handlePromise (APP_PATH\node_modules\node_modules\execa\index.js:124:26)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async <anonymous> (APP_PATH\node_modules\@wix\cli-astro-commands\src\commands\build.ts:29:9)
at async runCommand (APP_PATH\node_modules\@wix\cli-astro-commands\src\commands\render-command.tsx:116:5)
at async _Command.<anonymous> (APP_PATH\node_modules\@wix\cli-astro-commands\src\commands\build.ts:21:7)
at async _Command.parseAsync (APP_PATH\node_modules\node_modules\commander\lib\command.js:1104:5)
at async <anonymous> (APP_PATH\node_modules\@wix\cli\src\index.tsx:98:25)
Error Info
{}
@upper bison And that’s the only thing in debug.log?
Oddly, yes
Hmm, very odd! Could you clear debug.log and try and build again and see if produces the same single error or you see anymore errors?
I actually just did and yes that is the only message being logged
Error : Rollup failed to resolve import "astro:env/server" from ...
That error is to do with the import line. Could you comment the import line out and try and build again?
yes, it builds without that import
And you are calling that from the correct backend file right?
Src/pages/api/your-api-name.ts ??
Do you also see the secrets in your env.local file?
src\extensions\backend\service-plugins\posten-rates\bring-api.ts
yes, the secret is in env.local
Backend should be ‘src/pages/api/your-backend-file-name.ts’
This article shows you how to create an HTTP method in your CLI project and call it from your frontend to handle HTTP requests. These endpoints handle server-side logic and can return any kind of data to your frontend. To create an HTTP endpoint:
this is purly a shipping rates plugin, so it's not possible to access secrets from such plugin?
astro:env/server is for backend but looks like you are calling it from the frontend hence the error you are getting. It is possible to access secrets from your plugin…. If you are wanting the secrets on the backend then you need to use the correct backend directory as shown in the docs and call from your bring-api.ts file.
You can still get the secret from the backend but you need to correctly set up your backend as shown in the docs, otherwise you need to store your secrets on client side
Make sense?
shipping rates plugin is backend
I think this should be a bug that they don't support secrets in backend extensions
I did file a ticket already
I understand what you are saying but server secrets are only accessible through the proper backend directory.
I do understand that this is confusing.
The backend directory is src/pages/api/your-api-name.ts
I don’t understand why they have two different types of backend but for server secrets it needs to be called from src/pages/api/your-api-name.ts
I see
Totally understand that this is confusing for sure!
ok, will try that - thanks 🙂
Do come back here and let us know but pretty sure this will resolve the issue for you 🙂
@upper bison any luck?