Skip to content

Commit

Permalink
templates: fix preview path protocol not being https in production en…
Browse files Browse the repository at this point in the history
…vironments (#9910)
  • Loading branch information
paulpopus authored Dec 11, 2024
1 parent 821bd35 commit 6a09fe1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion templates/website/src/utilities/generatePreviewPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export const generatePreviewPath = ({ collection, slug, req }: Props) => {
encodedParams.append(key, value)
})

let url = `${req.protocol}//${req.host}/next/preview?${encodedParams.toString()}`
const isProduction =
process.env.NODE_ENV === 'production' || Boolean(process.env.VERCEL_PROJECT_PRODUCTION_URL)
const protocol = isProduction ? 'https:' : req.protocol

let url = `${protocol}//${req.host}/next/preview?${encodedParams.toString()}`

return url
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export const generatePreviewPath = ({ collection, slug, req }: Props) => {
encodedParams.append(key, value)
})

let url = `${req.protocol}//${req.host}/next/preview?${encodedParams.toString()}`
const isProduction =
process.env.NODE_ENV === 'production' || Boolean(process.env.VERCEL_PROJECT_PRODUCTION_URL)
const protocol = isProduction ? 'https:' : req.protocol

let url = `${protocol}//${req.host}/next/preview?${encodedParams.toString()}`

return url
}

0 comments on commit 6a09fe1

Please sign in to comment.