Skip to content

Commit

Permalink
[Netlify] Allow public URL detection (#1585)
Browse files Browse the repository at this point in the history
* [Netlify] Allow public URL detection

* use deploy specific URL at build time for Netlify

* Changelog entry

* jsdoc entry
  • Loading branch information
art-alexeyenko authored Aug 15, 2023
1 parent 2f68445 commit 771bf8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
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;
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`;

let url = process.env.PUBLIC_URL;
Expand Down

0 comments on commit 771bf8d

Please sign in to comment.