GithubHelp home page GithubHelp logo

sveltekit-reproduction's Introduction

Header Forwarding Problem

This project demonstrates a weird behavior where initial request headers are forwarded through to external fetch calls when using the svelte-kit node adapter.

You can see this by logging request headers in the externalFetch hook.

Steps to reproduce this issue:

First, run this server locally with yarn run dev.

Then cURL the request with the Accept header:

curl --header "Accept: text/html" http://localhost:3000

In the development console, you'll see that the Request object for the API URL also includes this header (and any other header that you provide):

External Fetch:
https://www.gov.uk/bank-holidays.json
Accept Header: text/htm

External Fetch:
https://www.gov.uk/bank-holidays.json
Accept Header: image/png

This header matches whatever is sent to the request for HTML when connecting to http://localhost:3000, even though this is a request for JSON data.

Why does this matter?

This is unexpected and causes problems for our API interactions. We've hit this in two places:

  • A client passes through Accept: image/png to our API endpoint, which results in our API responding with a 406 Not Acceptable error. This is fine ๐Ÿคท, but pretty weird.
  • More frustrating: a client passes through a If-Modified-Since header, our API returns a 304 Not Modified response, which raises an error when generating a server response.

We'd expect these headers to not get automatically passed through. Those headers are for the SvelteKit request, not our API.

sveltekit-reproduction's People

Contributors

nhunzaker avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.