Read public/CNAME for domain name in --externel-assets mode
This commit is contained in:
parent
fabd48a22c
commit
11d6a2020f
@ -295,7 +295,7 @@ If you are specifically building a theme to integrate with an app or a website t
|
||||
to first browse unauthenticated before logging in, you will get a significant
|
||||
performance boost if you jump through those hoops:
|
||||
|
||||
- Provide the url of your app in the `homepage` field of package.json. [ex](https://github.com/garronej/keycloakify-demo-app/blob/7847cc70ef374ab26a6cc7953461cf25603e9a6d/package.json#L2)
|
||||
- Provide the url of your app in the `homepage` field of package.json. [ex](https://github.com/garronej/keycloakify-demo-app/blob/7847cc70ef374ab26a6cc7953461cf25603e9a6d/package.json#L2) or in a `public/CNAME` file. [ex](https://github.com/garronej/keycloakify-demo-app/blob/main/public/CNAME).
|
||||
- Build the theme using `npx build-keycloak-theme --external-assets` [ex](https://github.com/garronej/keycloakify-demo-app/blob/7847cc70ef374ab26a6cc7953461cf25603e9a6d/.github/workflows/ci.yaml#L21)
|
||||
- Enable [long-term assets caching](https://create-react-app.dev/docs/production-build/#static-file-caching) on the server hosting your app.
|
||||
- Make sure not to build your app and the keycloak theme separately
|
||||
|
@ -4,6 +4,7 @@ import { join as pathJoin, relative as pathRelative, basename as pathBasename }
|
||||
import * as child_process from "child_process";
|
||||
import { generateDebugFiles, containerLaunchScriptBasename } from "./generateDebugFiles";
|
||||
import { URL } from "url";
|
||||
import * as fs from "fs";
|
||||
|
||||
type ParsedPackageJson = {
|
||||
name: string;
|
||||
@ -41,7 +42,17 @@ export function main() {
|
||||
const url = (() => {
|
||||
const { homepage } = parsedPackageJson;
|
||||
|
||||
return homepage === undefined ? undefined : new URL(homepage);
|
||||
if (homepage !== undefined) {
|
||||
return new URL(homepage);
|
||||
}
|
||||
|
||||
const cnameFilePath = pathJoin(reactProjectDirPath, "public", "CNAME");
|
||||
|
||||
if (fs.existsSync(cnameFilePath)) {
|
||||
return new URL(fs.readFileSync(cnameFilePath).toString("utf8").replace(/\s+$/, ""));
|
||||
}
|
||||
|
||||
return undefined;
|
||||
})();
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user