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

There is no way to access original node request #4784

Closed
itssumitrai opened this issue Apr 30, 2022 · 1 comment
Closed

There is no way to access original node request #4784

itssumitrai opened this issue Apr 30, 2022 · 1 comment

Comments

@itssumitrai
Copy link

Describe the problem

Sveltekit's handle hook throws away actual node request, and only supplies very minimal request information.

export async function getRequest(base, req) {

The node request information has tons of additional information like connection (ip address) and some critical information which is required for building enterprise apps. While in the handle hook we only get pretty minimal information which is not useful for a lot of use cases.

Describe the proposed solution

One way I can think of, which is pretty straightforward is basically also send in the original node request in the handle hook.
so the event could have request => Sveltekit's request object, and another property called nativeRequest which would actually be the actual node request.
The apps can use the native request object to get the node information which is not available currently.

Alternatives considered

Another solution which I think could work is when building the new Request object, also pass any locals.
so request.locals = req.locals. This would enable developers using custom node / express server to use any middlewares and then pass down the computed values through req.locals to Sveltekit's request object.
This could even be extended to a list of properties instead of just locals which could be set in adapter-node

Importance

i cannot use SvelteKit without it

Additional Information

I am working on an enterprise level application, and this is a critical functionality we would need in order to distinguish internal & external requests and do some custom authentication for our internal requests. We cannot use Sveltekit without this feature.

@Conduitry
Copy link
Member

Duplicate of #4654.

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

2 participants