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

How to access to params using dynamic route #30

Closed
AugustinMauroy opened this issue Apr 2, 2024 · 5 comments
Closed

How to access to params using dynamic route #30

AugustinMauroy opened this issue Apr 2, 2024 · 5 comments

Comments

@AugustinMauroy
Copy link

I thinks everytings is on title

@apteryxxyz
Copy link
Owner

The second parameter passed to the SOCKET function is an IncomingMessage object from the Node.js http module. You can use that to get everything related to the request including the URL.

@AugustinMauroy
Copy link
Author

Ok ! Thanks but why do you think about having something like that:

export function SOCKET({
  client: import('ws').WebSocket,
  request: import('http').IncomingMessage,
  server: import('ws').WebSocketServer,
  params: YourParamsType
}) {
  // ...
}

So parameter of function is one object. Like Get methods of next

@chinna2580
Copy link

@apteryxxyz dyamic path routes are not working using next-ws, it throws 'could not find module for page /api/socket/history' this is in path /api/socket/[api_type]/route.ts file, it doesnt read this path

@apteryxxyz
Copy link
Owner

@apteryxxyz dyamic path routes are not working using next-ws, it throws 'could not find module for page /api/socket/history' this is in path /api/socket/[api_type]/route.ts file, it doesnt read this path

Fixed in [email protected].

@apteryxxyz
Copy link
Owner

apteryxxyz commented Jul 12, 2024

Speaking of this issue, I'm gonna go ahead and close it, you can get the params from the request parameter. I want to avoid adding more parameters to the SOCKET function, and I'm not even sure if next-ws can access the names of dynamic segments.

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