ga-wdi-exercises/project4

port issue

Closed this issue · 3 comments

cwcox commented

repo link: https://github.com/cwcox/taylor

MEAN app using Angular4 not JS (though don't think the issue is with angular). Also using mondodb package instead of mongoose.

When using npm start, node server (server.js will run the app server), node serve, or nodemon the app will always run on port 4200, however the database will not/cannot be accessed on that port. It can only be accessed on port 3000.

I have set (hardcoded) port 3000 in all places that I can find:
package.json
protractor.conf.js
server/routes/api.js

I previously had the app working on port 3000, displaying data from the database. I tried to use nodemon, with runs on 4200, so I changed the port number in server.js to 4200 but got the below error in the console:

http://localhost:4200/api/songs Failed to load resource: the server responded with a status of 404 (Not Found).

I changed it back to 3000 and got the same error (but with the port changed).

There is data in my DB. I don't care which port the app runs on (though would like to use nodemon so i don't have to kill and reload the server with each change).

@cwcox First thing I'd try is where you set the port number in server.js, set it as a Number instead of a String:
https://github.com/cwcox/taylor/blob/master/server.js#L26

Change

'3000'

to

3000

@cwcox Also, probably looking at outdated code, but in server/routes/api.js, you're not listening for /api/songs, you're listening for /songs:
https://github.com/cwcox/taylor/blob/master/server/routes/api.js#L29-L43

cwcox commented

removed the "secure" piece in proxy.config.json and there was no changed, everything still worked.

Thanks for the help