Skip to content

fix(wujie): use placeholder origin for URL rewrite to avoid path duplication - #268

Merged
Gaubee merged 1 commit into
mainfrom
fix/wujie-url-rewrite
Jan 21, 2026
Merged

Gaubee merged 1 commit into
mainfrom
fix/wujie-url-rewrite

Conversation

@Gaubee

@Gaubee Gaubee commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Remote miniapp (rwa-hub) requests are being rewritten incorrectly:

Before (wrong):

Request: /assets/main.js
Rewritten: https://bioforestchain.github.io/KeyApp/webapp/miniapps/rwa-hub/KeyApp/webapp/miniapps/rwa-hub/assets/main.js

After (correct):

Request: /assets/main.js
Rewritten: https://bioforestchain.github.io/KeyApp/webapp/miniapps/rwa-hub/assets/main.js

Root Cause

The old code used string concatenation which duplicated the path:

const rewrittenUrl = `${origin}${parsedReqUrl.pathname}...`;
// origin = https://bioforestchain.github.io/KeyApp/webapp/miniapps/rwa-hub
// pathname = /KeyApp/webapp/miniapps/rwa-hub/assets/main.js
// Result: path duplicated!

Fix

Use placeholder origin approach to properly normalize the URL:

const normalized = new URL(
  parsedReqUrl.pathname + parsedReqUrl.search + parsedReqUrl.hash,
  PLACEHOLDER_ORIGIN + '/',
);
const rewrittenUrl = normalized.href.replace(PLACEHOLDER_ORIGIN + '/', targetBase);

This ensures the pathname is correctly resolved relative to the target base URL.

@Gaubee
Gaubee merged commit 7dcfc2a into main Jan 21, 2026
5 checks passed
@Gaubee
Gaubee deleted the fix/wujie-url-rewrite branch January 21, 2026 10:16
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