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

Running an express server from within cloud code #2993

Closed
mrnocreativity opened this issue Nov 2, 2016 · 3 comments
Closed

Running an express server from within cloud code #2993

mrnocreativity opened this issue Nov 2, 2016 · 3 comments

Comments

@mrnocreativity
Copy link

mrnocreativity commented Nov 2, 2016

In Parse.com I have several apps that start an express server from within the cloud code. In those express routes, I can get to the request.user object upon every page request.

With the new setup for Parse Server, the express server runs fully independent from the Parse server and the Parse API is served as middleware from a endpoint in the express server. That removes the possibility to capture the request.user. So forcing 'logged in' sessions seems to no longer be possible from a simple webpage request.

I have been trying to move things around but I seem to be unable to make this work.
Is this no longer possible?
I just don't want to be dependent on client-side JS to make my app work. I'd like to use the Parse Server as my core backend and generate complete pages.

Am I overlooking a way of getting the request.user from an express request? Or am I doing something wrong when setting up cloud code from the parse server?

@ghost
Copy link

ghost commented Nov 5, 2016

Hi @mrnocreativity .

I think you are looking to the same solution as I'm.
Check this issue #2985

@mrnocreativity
Copy link
Author

Hi @ronaldo-getreveel,

That looks exactly to be the solution, however, I hoped to be able to rely on the Parse Internals to do this by itself (like it did when the express server was hosted in the cloude code running on old parse.com).

I guess this will be it then :)
Thanks!

@mi3e
Copy link

mi3e commented Nov 13, 2016

Have an express middleware function that grabs the x-parse-session-token header from the request.
Then have it do a get request to https://your-parse-server-url.com/users/me with the same x-parse-session-token header.
If the session is valid (checks user is logged on, not expired etc etc) you'll get back a 200 and the user object in the response which can be parsed into an object using Parse.Object.fromJSON(response.body);

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