bradtraversy / meanauthapp

Complete MEAN stack app with authentication
242 stars 152 forks source link

Possible Register Bug #24

Open ryanwells-rwc opened 6 years ago

ryanwells-rwc commented 6 years ago

When attempting to register a new User, I'm getting this error: POST http://localhost:4200/users/register 404 (Not Found) Shouldn't the port be 8080 to access the Node routes file? It seems like the port is being incorrectly set to 4200 somewhere in the application, but I haven't found where yet. Is this happening for anyone else?

ryanwells-rwc commented 6 years ago

This may only be breaking with Angular 5 (which I'm currently using), as I see code like this still in the project: import 'rxjs/add/operator/map'; indicating it hasn't been migrated. Perhaps there are no plans or time to do so.

clevadani commented 6 years ago

I'm also facing this. Any idea how to tackle this?

tomcatbuzz commented 6 years ago

@ryanwells-rwc are you running this on a localhost or deployed? Update the app.js with this code // Port Number const port = process.env.PORT || 8080; If you are running test from local host you need that set to 3000 and have to have 1 console @project root running npm start or nodemon in port 3000. The other console is running at Angular-src with ng serve (port 4200). I have forked this repo and will sending changes soon. I am using Angular 5 and it works deployed.

tomcatbuzz commented 6 years ago

@ryanwells-rwc you are getting that error because the code has been finalized for deployment and no longer contains the http://localhost:3000 in the Auth.service.ts file in front of user/register. The port was changed in App.js to PORT || 8080 for deployment to heroku, you can comment that out and put const port = 3000; You have to add back the code like this for local testing in auth.services.ts return this.http.post('http://localhost:3000/users/register', user, {headers: headers}) do the same for authenticate and profile. After that change and the app.js change to port 3000 you can run ng serve in angular-src (root) for port 4200. From the project root run another console with npm start or nodemon and that will run the backend at localhost 3000. If you browse to Localhost:4200 you will have the main page. Hope this helps anyone.