Skip to content

Migration to v2, access to the request headers #1790

Closed Answered by ghostd
ghostd asked this question in Q&A
Discussion options

You must be logged in to vote

My bad, it is a TypeScript issue. In plain JS all is fine with this:

  http.get(`${urlPrefix}/api/v2/path`, async ({request}) => {
    if (request.headers.get("x-api-key") !== "secret-api-key") {
      return new HttpResponse(unauthorized401, { status: 401 });
    }
  }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ghostd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant