Skip to content

Commit

Permalink
chore: Fix env varibles in 404.html
Browse files Browse the repository at this point in the history
  • Loading branch information
sharat87 committed Nov 25, 2024
1 parent a320605 commit 56b10fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/client/public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
return result;
}

const smartLookId = parseConfig("__APPSMITH_SMART_LOOK_ID__");
const sentryDSN = parseConfig("__APPSMITH_SENTRY_DSN__");
const smartLookId = parseConfig('{{env "APPSMITH_SMART_LOOK_ID"}}');
const sentryDSN = parseConfig('{{env "APPSMITH_SENTRY_DSN"}}');
</script>
<script type='text/javascript'>
if(smartLookId) {
Expand Down
17 changes: 9 additions & 8 deletions deploy/docker/fs/opt/appsmith/caddy-reconfigure.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ if (CUSTOM_DOMAIN !== "") {
}

if (!process.argv.includes("--no-finalize-index-html")) {
finalizeIndexHtml()
finalizeHtmlFiles()
}

fs.mkdirSync(dirname(CaddyfilePath), { recursive: true })
fs.writeFileSync(CaddyfilePath, parts.join("\n"))
spawnSync(AppsmithCaddy, ["fmt", "--overwrite", CaddyfilePath])
spawnSync(AppsmithCaddy, ["reload", "--config", CaddyfilePath])

function finalizeIndexHtml() {
function finalizeHtmlFiles() {
let info = null;
try {
info = JSON.parse(fs.readFileSync("/opt/appsmith/info.json", "utf8"))
Expand All @@ -248,17 +248,18 @@ function finalizeIndexHtml() {
APPSMITH_VERSION_RELEASE_DATE: info?.imageBuiltAt ?? "",
}

const content = fs.readFileSync("/opt/appsmith/editor/index.html", "utf8").replaceAll(
/\{\{env\s+"(APPSMITH_[A-Z0-9_]+)"}}/g,
(_, name) => (process.env[name] || extraEnv[name] || "")
)
for (const file of ["index.html", "404.html"]) {
const content = fs.readFileSync("/opt/appsmith/editor/" + file, "utf8").replaceAll(
/\{\{env\s+"(APPSMITH_[A-Z0-9_]+)"}}/g,
(_, name) => (process.env[name] || extraEnv[name] || "")
)

fs.writeFileSync(process.env.WWW_PATH + "/index.html", content)
fs.writeFileSync(process.env.WWW_PATH + "/" + file, content)
}
}

function isCertExpired(path) {
const cert = new X509Certificate(fs.readFileSync(path, "utf-8"))
console.log(path, cert)
return new Date(cert.validTo) < new Date()
}

0 comments on commit 56b10fd

Please sign in to comment.