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

SSR fetch doesn't work for external requests #2028

Closed
koffeinfrei opened this issue Jul 28, 2021 · 2 comments
Closed

SSR fetch doesn't work for external requests #2028

koffeinfrei opened this issue Jul 28, 2021 · 2 comments

Comments

@koffeinfrei
Copy link

koffeinfrei commented Jul 28, 2021

Describe the bug

Using fetch in SSR treats requests as relative with the default config value of "" (empty string) for options.paths.base, instead of as an external request.

The reason is the statement

} else if (resolved.startsWith(options.paths.base || '/')) {
that always resolves to true with the default value.

Reproduction

<script context="module">
  export async function load({ fetch }) {
      const result = await fetch('https://duckduckgo.com/');
     // --> result is not from duckduckgo, but from the svelte-kit app
  }
</script>

Logs

No response

System Info

npx: installed 1 in 0.935s

  System:
    OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
    CPU: (4) x64 Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz
    Memory: 963.18 MB / 15.38 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 12.20.0 - ~/.nvm/versions/node/v12.20.0/bin/node
    Yarn: 1.12.3 - /usr/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v12.20.0/bin/npm
  Browsers:
    Chromium: 92.0.4515.107
    Firefox: 90.0

Severity

blocking all usage of SvelteKit

Additional Information

No response

@benmccann
Copy link
Member

Are you using the latest version of SvelteKit? This should have been fixed in #1980

https://duckduckgo.com/ doesn't start with / so I don't see from the code how it would fail

@koffeinfrei
Copy link
Author

Are you using the latest version of SvelteKit? This should have been fixed in #1980

Right, this has been fixed right between me detecting the bug and reporting it. Sorry for the noise.

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

No branches or pull requests

2 participants