Skip to content

Commit aa7410b

Browse files
authored
Merge pull request #940 from IgniteUI/gedinakova/public-url-fix
chore(*): Attempt to fix resolved url for service worker
2 parents b99ecb4 + 08c338b commit aa7410b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

browser/src/navigation/SamplesBuster.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class SamplesBuster extends React.Component<SamplesBusterProps, SamplesBu
7575
// metaURL = pathname + '/meta.json';
7676
// }
7777
console.log('SB version location: ' + pathname);
78-
console.log('SB version public: ' + process.env.PUBLIC_URL);
78+
console.log('SB version public: ' + import.meta.env.BASE_URL);
7979
try {
8080
const response = await fetch(metaURL);
8181
const metaJson = await response.json(); // may error if there is no body

browser/src/serviceWorker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ export default function register(): void {
2626
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
2727
// The URL constructor is available in all browsers that support SW.
2828
const publicUrl = new URL(
29-
process.env.PUBLIC_URL!,
29+
import.meta.env.BASE_URL!,
3030
window.location.toString()
3131
);
3232
console.log('SW reg public ' + publicUrl);
3333

3434
if (publicUrl.origin !== window.location.origin) {
35-
// Our service worker won't work if PUBLIC_URL is on a different origin
35+
// Our service worker won't work if BASE_URL is on a different origin
3636
// from what our page is served on. This might happen if a CDN is used to
3737
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
3838
return;
3939
}
4040

4141
window.addEventListener('load', () => {
42-
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
42+
const swUrl = `${import.meta.env.BASE_URL}/service-worker.js`;
4343

4444
console.log('SW load url ' + swUrl);
4545

0 commit comments

Comments
 (0)