Skip to content
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

[Netlify] Allow public URL detection #1585

Merged
merged 5 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Check the BYOC documentation for more info. ([#1568](https://github.com/Sitecore
* `[templates/nextjs]` `[templates/react]` `[templates/vue]` `[templates/angular]` Introduce layout service REST configuration name environment variable ([#1543](https://github.com/Sitecore/jss/pull/1543))
* `[templates/nextjs]` `[sitecore-jss-nextjs]` Support for out-of-process editing data caches was added. Vercel KV or a custom Redis cache can be used to improve editing in Pages and Experience Editor when using Vercel deployment as editing/rendering host ([#1530](https://github.com/Sitecore/jss/pull/1530))
* `[sitecore-jss-react]` Built-in MissingComponent component can now accept "errorOverride" text in props - to be displayed in the yellow frame as a custom error message. ([#1568](https://github.com/Sitecore/jss/pull/1568))
* `[sitecore-jss-nextjs]` Support for public URL resolution in Netlify ([#1585](https://github.com/Sitecore/jss/pull/1585))
* `[templates/nextjs]` `[sitecore-jss-nextjs]` Better error handling for component-level data fetching ([#1586](https://github.com/Sitecore/jss/pull/1586))

### 🧹 Chores
Expand Down
2 changes: 2 additions & 0 deletions packages/sitecore-jss-nextjs/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { isEditorActive, resetEditorChromes } from '@sitecore-jss/sitecore-jss/u
* This is set to http://localhost:3000 by default.
* VERCEL_URL is provided by Vercel in case if we are in Preview deployment (deployment based on the custom branch),
* preview deployment has unique url, we don't know exact url.
* Similarly, DEPLOY_URL is provided by Netlify and would give us the deploy URL
*/
export const getPublicUrl = (): string => {
if (process.env.NETLIFY && process.env.DEPLOY_URL) return process.env.DEPLOY_URL;
art-alexeyenko marked this conversation as resolved.
Show resolved Hide resolved
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`;

let url = process.env.PUBLIC_URL;
Expand Down