Skip to content

Commit

Permalink
Merge pull request #21 from sanity-io/next-13
Browse files Browse the repository at this point in the history
Next 13
  • Loading branch information
SimeonGriggs committed Jun 22, 2023
2 parents ad78a7c + bc49ede commit d04d88f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions studio/structure/resolvePreviewUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@ import {SanityDocument} from 'sanity'
import {getSecret, SECRET_ID} from './getSecret'

export default async function resolvePreviewUrl(doc: SanityDocument, client: SanityClient) {
const baseUrl =
process.env.NODE_ENV === 'development'
? `http://localhost:3000`
: `https://demo-course-platform-git-next-13.sanity.build`
let baseUrl = `http://localhost:3000`

// Use public vars because Studio is all client-side
if (process.env.SANITY_STUDIO_VERCEL_ENV) {
// This is the URL of the Studio deployment, not the web deployment
baseUrl = `https://${
process.env.SANITY_STUDIO_VERCEL_ENV === 'production'
? process.env.SANITY_STUDIO_VERCEL_URL?.replace(`-studio`, ``)
: // This should work, but doesn't
// the env seems to be `undefined` in vercel
// : process.env.SANITY_STUDIO_VERCEL_BRANCH_URL
// So I'm DIY-ing a branch URL for the web deployment
`demo-course-platform-git-${process.env.SANITY_STUDIO_VERCEL_GIT_COMMIT_REF}.sanity.build`
}`

console.log({baseUrl})
}

const {_id} = doc

Expand Down

2 comments on commit d04d88f

@vercel
Copy link

@vercel vercel bot commented on d04d88f Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

demo-course-platform-studio – ./studio

demo-course-platform-studio-git-main.sanity.build
demo-course-platform-studio.sanity.build

@vercel
Copy link

@vercel vercel bot commented on d04d88f Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

demo-course-platform – ./web

demo-course-platform-git-main.sanity.build
demo-course-platform.sanity.build

Please sign in to comment.