Skip to content

Data serialization is broken if you are using full URL to API on your hostname #8852

@stalkerg

Description

@stalkerg

Describe the bug

My API is on the same hostname but in sub path "/api". My fetch do things like fetch('https://my.site/api/get_user') .
The URL from this fetch is testing on the server side is here https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/server/page/load_data.js#L190 and removing the hostname from the URL because the origin is the same, but the client trying to search the full path by selector because we use fetch URL as is here https://github.com/sveltejs/kit/blob/master/packages/kit/src/runtime/client/client.js#L603 .

It raises the second request to API, from CSR.

Reproduction

In the load function, you should make a fetch with the full path to the same hostname.

Logs

No response

System Info

System:
    OS: Linux 5.4 Ubuntu 20.04.5 LTS (Focal Fossa)
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 37.92 GB / 62.81 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.12.1 - /usr/bin/node
    npm: 8.19.2 - /usr/bin/npm
  npmPackages:
    @sveltejs/adapter-node: 1.1.4 => 1.1.4 
    @sveltejs/kit: 1.3.9 => 1.3.9 
    @sveltejs/svelte-virtual-list: github:sveltejs/svelte-virtual-list => 3.0.1 
    svelte: 3.55.1 => 3.55.1 
    vite: ^4.0.4 => 4.0.4

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions