Skip to content

Commit

Permalink
#178 Another adjustment to basename/public URL route
Browse files Browse the repository at this point in the history
  • Loading branch information
Nospamas committed Feb 8, 2024
1 parent 66f7c7d commit 367da68
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ import "./index.css";

import registerServiceWorker from "./registerServiceWorker";

console.log("### process.env.PUBLIC_URL", process.env.PUBLIC_URL);
let baseName = "/";
if (process.env.PUBLIC_URL) {
if (process.env.PUBLIC_URL.indexOf(".") >= 0) {
baseName = new URL(process.env.PUBLIC_URL).pathname;
} else {
// for development
baseName = process.env.PUBLIC_URL;
}
}

console.log("### PUBLIC_URL", process.env.PUBLIC_URL);
console.log("### baseName", baseName);

// Code split our bundle along our primary routes using the "lazy" function.
// https://reactrouter.com/en/main/route/lazy
Expand All @@ -32,7 +43,7 @@ const router = createBrowserRouter(
</Route>,
),
{
basename: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : "/",
basename: baseName,
},
);

Expand Down

0 comments on commit 367da68

Please sign in to comment.