[SOLVED] Get query parameters from url on server? Use case Instagram oAuth

This is easy to do with a client side router or JS on the client. But since window is not an object on the server how would one get a query parameter or even read a url from the server? I checked node examples but couldn’t find anything that didn’t pertain to express js.

My use case is Instagram, It sends me back a code that needs to be read on the server and then I send a http request with that code from the server to retrieve an access token.

Basically I want to retrieve the query of “code” http://localhost:3000/?code=5e04c2e304f24f8b8380c2ec81202139 on the server.

Has to be on load, not load then send to server via client.

ANSWER

WebApp.connectHandlers.use("/", function(req, res, next) {
  console.log(req.query);
  // comment this if you redirect to another route
  next();
});

THANK YOU for your research and posting the answer.

I was using Iron Router and it was dropping off GET parameters when a user had a ? in the middle. It was treated as another parameter because of the Iron Router wrapper or whatever.

Using this webapp thing did the trick!

Thanks so much for posting the answer.