Skip to content

Allow for creation of environmental variables for self-hosting/and instance on a different domain/google cloud project#206

Open
samschooler wants to merge 1 commit intoexcalidraw:mainfrom
samschooler:ss-add-env-vars
Open

Allow for creation of environmental variables for self-hosting/and instance on a different domain/google cloud project#206
samschooler wants to merge 1 commit intoexcalidraw:mainfrom
samschooler:ss-add-env-vars

Conversation

@samschooler
Copy link
Copy Markdown

Currently the allowedOrigins are hard-coded. This PR adds the ability to customize this and a few other options via env vars.

This was prompted because the re-write removed the ability for a self hosted instance of excalidraw to export links.

Fix in previous version here: excalidraw/excalidraw#600
Relevant code in new version:

let allowOrigins = [
"excalidraw.vercel.app",
"https://dai-shi.github.io",
"https://excalidraw.com",
"https://www.excalidraw.com",
"https://math.preview.excalidraw.com",
];
if (!PROD) {
allowOrigins.push("http://localhost:");
}
const corsGet = cors();
const corsPost = cors((req, callback) => {
const origin = req.headers.origin;
let isGood = false;
if (origin) {
for (const allowOrigin of allowOrigins) {
if (origin.indexOf(allowOrigin) >= 0) {
isGood = true;
break;
}
}
}
callback(null, { origin: isGood });
});

My ideal would be to re-open cors so self-hosted versions can export using the excalidraw.com services.

My second best solution is this PR, coupled with a default removal of the hosted service env vars to avoid confusion.

…igins in index.ts; update README.md with new environment variable documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant