"Missing" projectId when using sanity v3 and nextjs15 when deploying sanity studio.
Unanswered
Sun bear posted this in #help-forum
Sun bearOP
I'm trying to deploy my sanity CMS using the cmd, sanity deploy/npx sanity deploy but i get this error:
I've tried rechecking spelling but everything seems fine. I can log the projectId on the home page (which is client side).
my sanity.config.js:
my .env.local:
my env.js:
my sanity.cli.js:
"message": "Configuration must contain `projectId`"
},
"eventId": null
}
I've tried rechecking spelling but everything seems fine. I can log the projectId on the home page (which is client side).
my sanity.config.js:
"use client";
import { visionTool } from "@sanity/vision";
import { defineConfig } from "sanity";
import { structureTool } from "sanity/structure";
// Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works
import { apiVersion, dataset, projectId } from "./sanity/env";
import { schema } from "./sanity/schemaTypes";
import { structure } from "./sanity/structure";
console.loh("projectId", projectId);
export default defineConfig({
basePath: "/",
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID || projectId,
dataset,
// Add and edit the content schema in the './sanity/schemaTypes' folder
schema,
plugins: [
structureTool({ structure }),
// Vision is for querying with GROQ from inside the Studio
// https://www.sanity.io/docs/the-vision-plugin
visionTool({ defaultApiVersion: apiVersion }),
],
});
my .env.local:
NEXT_PUBLIC_SANITY_PROJECT_ID="xxxxxx"
NEXT_PUBLIC_SANITY_DATASET="xxxxxxxx"
my env.js:
export const apiVersion =
process.env.NEXT_PUBLIC_SANITY_API_VERSION || "2024-11-30";
export const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET;
export const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID;
my sanity.cli.js:
import { defineCliConfig } from "sanity/cli";
const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID;
const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET;
const studioHost = "mcnet-solutions-portfolio";
export default defineCliConfig({
api: { projectId, dataset },
studioHost: studioHost,
});