|
|
@ -116,6 +116,12 @@ export function makeSendAppPage(opts: {
|
|
|
|
baseDomain?: string
|
|
|
|
baseDomain?: string
|
|
|
|
}) {
|
|
|
|
}) {
|
|
|
|
const {server, staticDir, tag, testLogin} = opts;
|
|
|
|
const {server, staticDir, tag, testLogin} = opts;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If env var GRIST_INCLUDE_CUSTOM_SCRIPT_URL is set, load it in a <script> tag on all app pages.
|
|
|
|
|
|
|
|
const customScriptUrl = process.env.GRIST_INCLUDE_CUSTOM_SCRIPT_URL;
|
|
|
|
|
|
|
|
const insertCustomScript: string = customScriptUrl ?
|
|
|
|
|
|
|
|
`<script src="${customScriptUrl}" crossorigin="anonymous"></script>` : '';
|
|
|
|
|
|
|
|
|
|
|
|
return async (req: express.Request, resp: express.Response, options: ISendAppPageOptions) => {
|
|
|
|
return async (req: express.Request, resp: express.Response, options: ISendAppPageOptions) => {
|
|
|
|
const config = makeGristConfig({
|
|
|
|
const config = makeGristConfig({
|
|
|
|
homeUrl: !isSingleUserMode() ? server.getHomeUrl(req) : null,
|
|
|
|
homeUrl: !isSingleUserMode() ? server.getHomeUrl(req) : null,
|
|
|
@ -153,6 +159,7 @@ export function makeSendAppPage(opts: {
|
|
|
|
.replace("<!-- INSERT BASE -->", `<base href="${staticBaseUrl}">` + tagManagerSnippet)
|
|
|
|
.replace("<!-- INSERT BASE -->", `<base href="${staticBaseUrl}">` + tagManagerSnippet)
|
|
|
|
.replace("<!-- INSERT LOCALE -->", preloads)
|
|
|
|
.replace("<!-- INSERT LOCALE -->", preloads)
|
|
|
|
.replace("<!-- INSERT CUSTOM -->", customHeadHtmlSnippet)
|
|
|
|
.replace("<!-- INSERT CUSTOM -->", customHeadHtmlSnippet)
|
|
|
|
|
|
|
|
.replace("<!-- INSERT CUSTOM SCRIPT -->", insertCustomScript)
|
|
|
|
.replace(
|
|
|
|
.replace(
|
|
|
|
"<!-- INSERT CONFIG -->",
|
|
|
|
"<!-- INSERT CONFIG -->",
|
|
|
|
`<script>window.gristConfig = ${jsesc(config, {isScriptContext: true, json: true})};</script>`
|
|
|
|
`<script>window.gristConfig = ${jsesc(config, {isScriptContext: true, json: true})};</script>`
|
|
|
|