Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add access to original request object in hook and endpoints #1615

Closed
cupcakearmy opened this issue May 31, 2021 · 6 comments
Closed

Add access to original request object in hook and endpoints #1615

cupcakearmy opened this issue May 31, 2021 · 6 comments

Comments

@cupcakearmy
Copy link

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 #1610.

@mromanuk
Copy link

mromanuk commented 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 #887 (comment)

@cupcakearmy
Copy link
Author

yes, but hooks also get access to just the same request of the endpoints, so no luck there.
The solution proposed in #887 would probably work, but it's to janky for a production service imo :)

@benmccann
Copy link
Member

Client IP address is already available in the SvelteKit request. It's in the HTTP headers

@cupcakearmy
Copy link
Author

@benmccann can you provide docs/example? I only get host and origin headers. Nothing about an ip address

@benmccann
Copy link
Member

What adapter are you using and where are you hosting it?

@cupcakearmy
Copy link
Author

cupcakearmy commented 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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants