-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error When Viewing Deployed Studio Project #123
Comments
Further ContextSo I originally encountered this issue from a version of the this template when it was in this state back in October: Now it looks like the import { apiVersion, dataset, previewSecretId, projectId } from 'lib/sanity.api' Now, when trying to reproduce, I get my error at step 3 when trying to deploy (can't deploy to sanity):
|
I'm seeing this aswell. |
@magicspon my solution from this discussion may help: sanity-io/sanity#3926 (comment) However, note that I added this in to the template before the addition of |
whats the fix for this? |
yes please |
any fix here? |
Expected Behavior:
When I deploy the sanity project to the hosted Studio version, I should be able to access and use it at the set subdomain, i.e.
your-project.sanity.studio
.Actual Behavior:
The Studio crashes with error:
Error references file
/static/sanity.3279a857.js:4558:3169
The studio does not crash locally or from blog domain
/studio
.Steps To Reproduce:
.env
are referencing your Sanity projectnpx @sanity/cli@dev-preview deploy
sanity deploy
with the current v3Uncaught error: process is not defined
Context
This template seems to be only configured for the self-hosted Studio at
http://localhost:3000/studio
or your domain/studio
path.The sanity.config.ts file uses the node process object to access the env file. Since the Studio is a static client-side application,
process
is not available there and is thereforeundefined
.Sanity's v2 - v3 migration guide gives a work around for this by setting the appropriate values in your env file that will be bundled and exposed within
import.meta.env
. Theses variables must start withSANITY_STUDIO_
in the name.Possible Solution:
We can accommodate both by conditionally using
process.env.NEXT_PUBLIC_SANITY_PROJECT_ID
orimport.meta.env.SANITY_STUDIO_PROJECT_ID
depending on ifprocess.env
is defined.This is a little tricky since we'll have to first check if
window
is not'undefined'
(referencing something like this), so on the client-side version we can set a process attribute that would allow us to check for it in the config file without causing errors.Within TypeScript will have to reference some interfaces for
import.meta
as well, within aenv.d.ts
file.I've got this working on my personal site.
The text was updated successfully, but these errors were encountered: