Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only use local sandbox if same origin #2684

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/altair-core/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import { UrlConfig, urlMap } from './urls';

const isTranslateMode = (window as TODO).__ALTAIR_TRANSLATE__;

const parseUrl = (url: string) => {
try {
return new URL(url);
} catch (e) {
return;
}
};
export class AltairConfig {
private localSandboxUrl: string | undefined;
private useLocalSandboxUrl = false;
Expand Down Expand Up @@ -135,7 +142,10 @@ export class AltairConfig {

private getPossibleLocalSandBoxUrl() {
// check document base url
if (document.baseURI) {
if (
document.baseURI &&
parseUrl(document.baseURI)?.origin === window.location.origin
) {
// add iframe-sandbox path to base url
if (document.baseURI.endsWith('/')) {
return new URL(document.baseURI + 'iframe-sandbox/index.html');
Expand Down
Loading