Using Webstorm with Udemy AngularJS course by Dan Wahlin

I recently took the course AngularJS Jumpstart with Dan Wahlin on Udemy. Dan does a great job and I highly recommend it. In the course Dan uses the Brackets editor which has the advantage of being able to set your project as the root of the server. This results in addresses such as:

“localhost:8080/index.html”

I use Webstorm for Angular and JavaScript development. I could not find any way to get it to do this and ended up addresses like:

“localhost:63342/Angular/index.html”

The problem comes in when you use the node.js server for the course application. Changing the server port to use 63342 causes a cross domain load error. To get the application to work with Webstorm first modify the server.js node/Express file:

1

2

3

4

5

6

7

var allowedOrigin = 'http://localhost:63342';

app.get('/customers', function(req, res){

// Add the following line to fix cross domain errors

res.header('Access-Control-Allow-Origin', allowedOrigin);

res.json(customers);

});

Then for each app.get in the file add the res.header line. There are other ways to do this such as using a router or a specialized middleware routine but this is the most straightforward way.

Next modify the customerFactory.js file to retrieve data from the 8080 port instead of defaulting to the application 63342 port:

About

I am a software developer living in Atlanta and occasionally writing about development, travel, electronics, and other related
items. Most of the code posted can be found at
Github. Leave a response to any post to contact me or message me at
Twitter.