Skip to content

Commit 4cd13a4

Browse files
committed
Fix URL alteration bug.
1 parent 7c8d525 commit 4cd13a4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ app.use(async ctx => {
4848
}
4949
};
5050
} else {
51-
const resp = await fetch(
52-
`${apiBaseUrl}${ctx.request.requestTarget}?embed=true`, {
53-
headers: {
54-
Accept: 'application/json'
55-
}
51+
const newUrl = new URL(`${apiBaseUrl}${ctx.request.requestTarget}`);
52+
if(!newUrl.searchParams.has('embed')) {
53+
newUrl.searchParams.append('embed', 'true');
54+
}
55+
const resp = await fetch(newUrl, {
56+
headers: {
57+
Accept: 'application/json'
5658
}
57-
);
59+
});
5860
const rv = await resp.json();
5961
const localhosted = JSON.stringify(rv).replaceAll(apiBaseUrl, '');
6062
ctx.response.body = localhosted;

0 commit comments

Comments
 (0)