Parse, NodeJS and CORS

A beautiful trio.

Eliseu C. Martinho
Oct 11, 2015 · 2 min read

This September, made a post on how to use nodejs with their javascript SDK. With this, one can develop on, using the javascript SDK and be able to debug the code, without doing the dreadful, code, deploy, run and watch the thousand lines of logs.

Actually you can run javascript SDK on nodejs for a long time. Yamill Vallecillo wrote a post this stuff. He has a small tutorial on how you can do it. The npm link for the parse library can be found here.

When I started working with, the first projects were very simple. Yet the more complex the projects got, the more the need to use other libraries increased. already has a number of useful libraries such as moment.js and parse-image, to name a few. Yet they are either outdated or limited. Since I was in a javascript/nodejs environment, I started looking for libraries on npm. For a moment, it seemed cool, however there’s the dependencies issue. For standalone libraries, it is fairly easy to integrate them in a parse project. You just download it with npm and copy it into a folder of your choice. When there are other dependencies, you download all of them, fix their path and add them all to your project, or you can use browserify to have it all in a bundled file.

One of the issues with the projects that I have is the need to develop API’s that will be consumed by either mobile apps or web apps, served by a particular domain. Because of SOP (Single Origin Policy), this means I need to have a way to get around it. CORS (Cross-Origin Resource Sharing) is the answer. For those who are new to CORS, there’s this excellent website about it. Fortunately there’s this library for expressjs. does not have CORS out of the box. Either you have to add the needed routing rules with the right headers to support it, or you can just download the library that does just that for you.

Let me take you step by step.

  1. Make sure you have parse installed. Just copy the command from here.

curl -s | sudo /bin/bash

2. Get the CORS library at

3. Copy the two files vary and cors: vary.js and cors.js.

4. Change the path on vary.js


5. Add these two lines where instantiated your expressjs app.

And voila. You have CORS. Happy coding.

Eliseu C. Martinho

Written by

suuuuper fahrrad byte surfer