#Using astro:env/server in shipping rates plugin fails to build

25 messages · Page 1 of 1 (latest)

upper bison
#
> npm run build
...
12:45:00 [ERROR] [vite] ✗ Build failed in 216ms
12:45:00 [ERROR] [@wix/astro] An unhandled error occurred while running the "astro:build:setup" hook
transforming (101) node_modules\@wix\sdk-runtime\build\utils.js[vite]: Rollup failed to resolve import "astro:env/server" from ...
glacial drum
#

@upper bison to confirm have you followed the docs exactly?

https://dev.wix.com/docs/wix-cli/guides/development/environment-variables/manage-environment-variables

if possible, it maybe worth posting your debug.log file 🙂

upper bison
#

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
{}
glacial drum
#

@upper bison And that’s the only thing in debug.log?

upper bison
#

Oddly, yes

glacial drum
# upper bison 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?

upper bison
#

I actually just did and yes that is the only message being logged

glacial drum
#

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?

upper bison
#

yes, it builds without that import

glacial drum
#

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?

upper bison
#

src\extensions\backend\service-plugins\posten-rates\bring-api.ts

#

yes, the secret is in env.local

glacial drum
upper bison
#

this is purly a shipping rates plugin, so it's not possible to access secrets from such plugin?

glacial drum
# upper bison this is purly a shipping rates plugin, so it's not possible to access secrets fr...

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?

upper bison
#

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

glacial drum
# upper bison shipping rates plugin is backend

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

upper bison
#

I see

glacial drum
#

Totally understand that this is confusing for sure!

upper bison
#

ok, will try that - thanks 🙂

glacial drum
#

Do come back here and let us know but pretty sure this will resolve the issue for you 🙂

glacial drum
#

@upper bison any luck?