-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle relative assets paths in server
fetch
correctly (#12113)
Fixes #12081 (and maybe helps with #3850). --------- Co-authored-by: Tee Ming <[email protected]>
- Loading branch information
1 parent
5780deb
commit df48fc6
Showing
11 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@sveltejs/adapter-cloudflare-workers": patch | ||
"@sveltejs/adapter-cloudflare": patch | ||
"@sveltejs/adapter-netlify": patch | ||
"@sveltejs/kit": patch | ||
--- | ||
|
||
fix: correctly handle relative paths when fetching assets on the server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/kit/test/apps/basics/src/routes/endpoint-output/fetch-asset/absolute/+server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import file_path from '../test.txt?url'; | ||
|
||
/** @type {import('@sveltejs/kit').RequestHandler} */ | ||
export async function GET({ url }) { | ||
const absolute = new URL(file_path, url.origin); | ||
|
||
const response = await fetch(absolute); | ||
|
||
return new Response(response.body, { | ||
headers: { | ||
'Content-Type': response.headers.get('Content-Type') | ||
} | ||
}); | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/kit/test/apps/basics/src/routes/endpoint-output/fetch-asset/relative/+server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import file_path from '../test.txt?url'; | ||
|
||
/** @type {import('@sveltejs/kit').RequestHandler} */ | ||
export async function GET({ fetch }) { | ||
const response = await fetch(file_path); | ||
|
||
return new Response(response.body, { | ||
headers: { | ||
'Content-Type': response.headers.get('Content-Type') | ||
} | ||
}); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/kit/test/apps/basics/src/routes/endpoint-output/fetch-asset/test.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Cos sie konczy, cos zaczyna |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters