Skip to content

New server-side fetch implementation introduces new CORS errors #6644

Description

@bothness

Describe the bug

This new implementation of server-side fetch is causing at least one of my Svelte Kit apps to break.
#6550

I am now receiving a 500 CORS error when fetching a Google spreadsheet as CSV, which does not give me CORS errors when loaded using browser fetch (or with the previous Svelte Kit server side fetch).

Reproduction

Fetch any Google spreadsheet as a CSV in a load() function within a +layout.js or a +page.js file, eg.

const url = "https://docs.google.com/spreadsheets/d/1mTdWRKo8AnJhKjBkqlonWlHoxIrdtZoqMnOkj_KMYvA/gviz/tq?tqx=out%3Acsv&sheet=Sheet1";

export async function load({ fetch }) {
	let response = await fetch(url);
	return true;
}

Logs

CORS error: No 'Access-Control-Allow-Origin' header is present on the requested resource
Error: CORS error: No 'Access-Control-Allow-Origin' header is present on the requested resource
    at fetch (.../node_modules/@sveltejs/kit/src/runtime/server/page/fetch.js:100:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async fetcher (.../node_modules/@sveltejs/kit/src/runtime/server/page/fetch.js:63:20)
    at async Module.getPlaces (/src/lib/utils.js:4:12)
    at async load (/src/routes/+layout.js:8:15)
    at async load_data (.../node_modules/@sveltejs/kit/src/runtime/server/page/load_data.js:109:15)
    at async .../node_modules/@sveltejs/kit/src/runtime/server/page/index.js:165:13

System Info

System:
    OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
    Memory: 4.73 GB / 6.08 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.64 
    @sveltejs/adapter-static: ^1.0.0-next.31 => 1.0.0-next.39 
    @sveltejs/kit: ^1.0.0-next.476 => 1.0.0-next.476 
    svelte: ^3.46.0 => 3.49.0 
    vite: ^3.1.0 => 3.1.0

Severity

blocking an upgrade

Additional Information

The response from Google doesn't seem to include an 'Access-Control-Allow-Origin' header, but this has never caused problems before (I guess there is something else in the settings/headers that's preventing a CORS error in the browser?). Obviously, I don't have a way to control the headers that Google returns, and not being able to use the sheet as a data source would basically break my app.

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