Skip to content
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
2 changes: 1 addition & 1 deletion browser/src/navigation/SamplesBuster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class SamplesBuster extends React.Component<SamplesBusterProps, SamplesBu
// metaURL = pathname + '/meta.json';
// }
console.log('SB version location: ' + pathname);
console.log('SB version public: ' + process.env.PUBLIC_URL);
console.log('SB version public: ' + import.meta.env.BASE_URL);
try {
const response = await fetch(metaURL);
const metaJson = await response.json(); // may error if there is no body
Expand Down
6 changes: 3 additions & 3 deletions browser/src/serviceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ export default function register(): void {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(
process.env.PUBLIC_URL!,
import.meta.env.BASE_URL!,
window.location.toString()
);
console.log('SW reg public ' + publicUrl);

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

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

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

Expand Down