angular2-authentication-sample icon indicating copy to clipboard operation
angular2-authentication-sample copied to clipboard

Server URL is hardcoded all over the place

Open dimitrovs opened this issue 9 years ago • 1 comments

If you look at: signup.ts, login.ts, home.ts you see the API URL is hardcoded everywhere:

http://localhost:3001/users http://localhost:3001/sessions/create http://localhost:3001/api/random-quote http://localhost:3001/api/protected/random-quote

You may argue that it doesn't matter, because it's just a "sample" app and users won't be deploying it anywhere, but the truth is hardcoding API URL like this is just bad design. You should have one variable defined in a common place with the API host then use relative paths everywhere else. Otherwise the incentive is too high for the novice user to just replace localhost:3001 with their domain and build a production app with this bad practice. In fact, there already is an issue asking how to do exactly that #52 .

dimitrovs avatar Jul 03 '16 18:07 dimitrovs

Hardcoding the URL isn't ideal and you're right, it's just a sample app which is why :)

Want to send a PR to centralize the URL?

chenkie avatar Jul 04 '16 13:07 chenkie