kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 195 forks source link

[flow-router-ssr][question] Is there a way to get the connection info on server with ssr ? #614

Closed TimoRuetten closed 8 years ago

TimoRuetten commented 8 years ago

When I call a method on client on server inside a route I will get the connection information with this.connection. On Server (when called on SSR) this.connection is always null. I tried to take a look at the Flowrouter.ssrContext but it seems that there are just HTML information located and not the connection context.

Is there any way to get information about the connection in SSR ?

Would be nice to get an answer.

SachaG commented 8 years ago

Did you find a workaround? See also https://github.com/kadirahq/flow-router/issues/640

TimoRuetten commented 8 years ago

Hey @SachaG - I've wrote me a small workaround you can find here as a package:

https://github.com/TimoRuetten/meteor-flow-router-ssr-request

You can add it easily with meteor add timoruetten:flow-router-ssr-request and then you are able to access FlowRouter.lastRequest() to return the connection info on Server Side.

SachaG commented 8 years ago

Looks like a great package, thanks! But I haven't been able to get the same connection/session ID you can access inside a publication with this.connection.id. Is there another unique ID you would suggest I use instead?

TimoRuetten commented 8 years ago

Hm - I'm sorry. I do not know enough about the connection/session id. The only thing my package is doing is to assign the last request object from Picker to the FlowRouter-SSR because I was not able to access it. I am sorry if this object does not contains the information you are needing.

But just a little hint: FlowRouter-SSR is using Picker for its routes. So if its not possible to access this variable in a regular request object I think you will have problems to get this. The thing is: In this Picker I think you are also not able to access the userId and other stuff Meteor is automatically assigning to Methods and publications.

TimoRuetten commented 8 years ago

But if you find a solution please let me know - I will then assign this to my package. Maybe some one else or even me will need this information of connection.