Skip to content

Either expose HTTP Header to Javascript or expose the cookies to fetch API's response #1947

Description

@peperronii

What problem are you trying to solve?

Right now there are two main ways to attach arbitrary data to a HTTP response

  1. a custom HTTP Header
  2. a Cookie

However, we can neither access the current page header via javascript nor read the cookies from a fetch response. That means when we build the logic for the server, if I want to send an arbritary data outside of the body of the response and intend to use it in a per Request Basis, It is very awkward to do so.

And even though the cookie from a fetch response via document.cookie but if there are many fetch request happening in a page it would either face race conditions or unneccessarily populate cookie names for each fetch site and/or request

Therefore, We should have a unified way to send some data apart from the body of the response that can be read by both the page request and the fetch request.

What solutions exist today?

Right now, the backend logic would have to seperate the fetch request from the normal page request, and choose to send the data in the corresponding format.

  • Cookie for a normal request
  • Header for a fetch request

OR

Send both at the same time.

How would you solve it?

Either expose HTTP Header to Javascript runtime or expose response cookies to fetch API

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions