Unlock seamless workflows and faster delivery with our latest releases – get the details

Sanity CLI login issues in GitHub Codespaces environment

3 replies
Last updated: Nov 30, 2024
Hi,
I'm running into a slightly annoying blocker. Most operations with the sanity CLI require you to login before usage. However, I'm working in a Github Codespace.


 bun run sanity deploy
The CJS build of Vite's Node API is deprecated. See <https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated> for more details.

Error: You must login first - run "sanity login"
    at /workspaces/mono/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:7049:13
    at Object.deployStudioAction [as default] (/workspaces/mono/node_modules/sanity/lib/_chunks-cjs/deployAction.js:21:167)
error: "sanity" exited with code 1
Codespaces proxy localhost and therefore the login callback is incorrect when open the login URL on my local pc


bun run sanity login
? Login type Google

Please open a browser at <https://api.sanity.io/v1/auth/login/google?type=token&label=codespaces-><>Linux&origin=http%3A%2F%2Flocalhost%3A4321%2Fcallback
Waiting for browser login to complete... Press Ctrl + C to cancel
I've tried to set
SANITY_AUTH_TOKEN
in my env but it still asks me to login all the time. I don't see an obvious way to resolve this. I can't even generate a project from template because it asks for login.
Nov 28, 2024, 6:01 PM
I was actually able to get the
SANITY_AUTH_TOKEN
to work, seems it was unset by me at some point. But would still be nice to be able to login.
Nov 28, 2024, 10:45 PM
Happy to hear you got this working. The login process requires a browser, so using the env variable like this is the canonical approach.
Nov 29, 2024, 6:26 PM
Yeah, as suggestion some other cli's like
gcloud
for example provide
--console-only
or
--no-launch-browser
options where you can copy paste the link on a different machine and login there then copy a code back over. https://cloud.google.com/sdk/docs/authorizing
but understandable if its not a high priority thing given there is a workaround.
Nov 30, 2024, 11:29 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?