question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add access to original request object in hook and endpoints

See original GitHub issue

Is your feature request related to a problem? Please describe.

Yes, we need to verify some IPs in the endpoints but there is no way to get that in the current state of svelte kit (please correct me if i’m wrong 😃

Describe the solution you’d like

I love that the normal Request object is parsed by default so that for most of the endpoints/api there is no need to add middleware. However there might be cases where this is not enough, as for example getting the IP of the connectiong client. Exposing the raw request as rawRequest e.g. could be a solution where most edge cases should become solvable. We already have rawBody.

Describe alternatives you’ve considered

None came to mind.

How important is this feature to you?

Quite important, withouth the ability to get the client IP we can not use kit for the current project unfortunately.

Additional context

Might be related to https://github.com/sveltejs/kit/issues/1610.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mromanukcommented, Jun 1, 2021

Have you seen hooks? https://kit.svelte.dev/docs#hooks If you want to access raw request, you will need to do something like this https://github.com/sveltejs/kit/issues/887#issuecomment-817327725

0reactions
cupcakearmycommented, Jun 2, 2021

For some reason I was expecting it to work in localhost. Dumb mistake xD I tried with a vercel deployment and it works well, thanks for responding 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to access request.body from the endpoint.js in sveltekit ...
When I add const data = await request.json(), when compile using npm run dev, I get an error that request.json() is not a...
Read more >
Advanced Usage — Requests 2.28.1 documentation
This document covers some of Requests more advanced features. Session Objects¶. The Session object allows you to persist certain parameters across requests. It ......
Read more >
How To Call Web APIs with the useEffect Hook in React
In this tutorial, you'll use the useEffect and useState React Hooks to fetch and display information in a sample application, ...
Read more >
Routes and Endpoints | REST API Handbook
Overview The REST API provides us a way to match URIs to various resources in our WordPress install. By default, if you have...
Read more >
API Slices: React Hooks | Redux Toolkit
The general format is use(Endpointname)(Query|Mutation) - use is prefixed, the first letter of your endpoint name is capitalized, then Query or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found