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

Possible to share session from express? #430

Closed
derrickpelletier opened this issue Jan 7, 2016 · 2 comments
Closed

Possible to share session from express? #430

derrickpelletier opened this issue Jan 7, 2016 · 2 comments

Comments

@derrickpelletier
Copy link

I'm wanting to use the users session in my nightmare instance, to generate a pdf.

Is it possible to somehow push the express session for the request into the nightmare instance when initialized?
#398 seemed like it might have been relevant but not sure how to use those suggestions towards what I need.

@rosshinkley
Copy link
Contributor

The short answer: possibly, but it would require a lot of effort and (probably frustrating) experimentation, and I suspect whatever implementation you came up with would be flaky at best. #398 (I believe) is more at sharing sessions across Nightmare instances, possibly across machines.

A slightly longer answer: I also suspect based on what you said that you're doing this on the server where the Express instance lives. If that's the case, you already have access to the user session, consequently the information you need, and can build the HTML required for the PDF there. That buys you a couple of options off the top of my head:

  1. Expose a new unauthenticated web method that examines the headers for a unique key, then have Nightmare add the key to the headers for the request. Not exactly the most secure option, but it would work.
  2. Use the same approach as option 1, but in a different service that isn't publicly exposed.
  3. Write the HTML to disk in a temporary file, and point Nightmare to that file.

@derrickpelletier
Copy link
Author

Thanks for your feedback. Yeah, my inclination is that it would be quite hacky. I'm not super familiar with sessions but it sort of seems like it goes against the core of what sessions are for.

I had already implemented what you suggested as point 2, so I'll probably just roll with that.

Thanks!

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

No branches or pull requests

2 participants