zackargyle/angularjs-django-rest-framework-seed

Great project, but a few questions

Closed this issue · 6 comments

Thanks for doing this. Your work here is very much needed! I was doing this work on a remote server and so had to adjust all your instructions not to run on localhost. Without any serious trouble, I got the nodejs server online and was presented with a login page.

However none of the users that I initially created would work for authentication. Looking at chrome's network traffic, I see REST calls to users, addresses and api-token-auth all being answered with:

XMLHttpRequest cannot load http://<my-ip>:8001/users.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://<my-ip>:8000' is therefore not allowed access.

Do you have any notion for why this is occurring? Also, It's not clear to me why it is that you've set up the nodejs server separate from the Django server instead of delivering the js content with Django's static file system. Seems like this would be far simpler to get off the ground with just Django, and people can transition to an external server later when they want to go to production?

Hey man,

If you haven't found anything online yet, it looks like a
django-cors-headers issue. If you go into Django/project/local_settings.py
at the bottom you will see CORS_ORIGIN_WHITELIST. If I'm right all you
need to do is add your http://:8001 to that list, and Django will
accept requests without swearing at you.

Hope that helps,
Zack

On Wed, Jan 29, 2014 at 2:34 AM, Peter Banka notifications@github.comwrote:

Thanks for doing this. Your work here is very much needed! I was doing
this work on a remote server and so had to adjust all your instructions not
to run on localhost. Without any serious trouble, I got the nodejs server
online and was presented with a login page.

However none of the users that I initially created would work for
authentication. Looking at chrome's network traffic, I see REST calls to
users, addresses and api-token-auth all being answered with:

XMLHttpRequest cannot load http://:8001/users.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://:8000' is therefore not allowed access.

Do you have any notion for why this is occurring? Also, It's not clear to
me why it is that you've set up the nodejs server separate from the Django
server instead of delivering the js content with Django's static file
system. Seems like this would be far simpler to get off the ground with
just Django, and people can transition to an external server later when
they want to go to production?

Reply to this email directly or view it on GitHubhttps://github.com//issues/3
.

Zack Argyle
Software Engineer

PS, random question. I just looked you up on github and saw your from
Portland (stalker, it's all good). I'm looking at moving to the northwest
this Spring, any cool places to work I should look up?

On Wed, Jan 29, 2014 at 7:26 AM, Zack Argyle zargyle@verisagellc.comwrote:

Hey man,

If you haven't found anything online yet, it looks like a
django-cors-headers issue. If you go into Django/project/local_settings.py
at the bottom you will see CORS_ORIGIN_WHITELIST. If I'm right all you
need to do is add your http://:8001 to that list, and Django will
accept requests without swearing at you.

Hope that helps,
Zack

On Wed, Jan 29, 2014 at 2:34 AM, Peter Banka notifications@github.comwrote:

Thanks for doing this. Your work here is very much needed! I was doing
this work on a remote server and so had to adjust all your instructions not
to run on localhost. Without any serious trouble, I got the nodejs server
online and was presented with a login page.

However none of the users that I initially created would work for
authentication. Looking at chrome's network traffic, I see REST calls to
users, addresses and api-token-auth all being answered with:

XMLHttpRequest cannot load http://:8001/users.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://:8000' is therefore not allowed access.

Do you have any notion for why this is occurring? Also, It's not clear to
me why it is that you've set up the nodejs server separate from the Django
server instead of delivering the js content with Django's static file
system. Seems like this would be far simpler to get off the ground with
just Django, and people can transition to an external server later when
they want to go to production?

Reply to this email directly or view it on GitHubhttps://github.com//issues/3
.

Zack Argyle
Software Engineer

Zack Argyle
Software Engineer

Thanks for the quick response, I'm new to CORS, so thanks for the suggestion.

As for Portland, basically everyone is hiring. It is very hard to find good Python programmers and they get snapped up fast. Anyone with any skill is working. Here's one lead, for example: http://siliconflorist.com/jobs/view/django-web-developer-sr-jr

Also, the Python Users Group is very strong in town (http://www.meetup.com/pdxpython/) When you arrive, I suggest attending regular meetings and getting involved with that community. Also, they have a strong IRC channel on Freenode #pdxpython. If you have any thoughts of moving to the the area, go ahead and log on now to the channel and get to know people. They are very friendly and if you ask about opportunities they will give you more current leads than I can.

Hello,

I'm reviving this thread, as my problem is very alike. I've followed the instructions and are trying to login at http://localhost:8000/app/index.html, but whatever I try, I can't login. When I submit my credentials, the chrome console responds with

POST http://localhost:8001/api-token-auth/ 401 (UNAUTHORIZED) angular.js:9253
(anonymous function) angular.js:9253
sendReq angular.js:9087
$http angular.js:8878
$http.(anonymous function) angular.js:9033
(anonymous function) directives.js:56
(anonymous function) angular.js:1972
forEach angular.js:131
eventHandler

which prevents me from even trying to view my data.
I'm pretty new to both AngularJS and Django and are don't really have the need to require login to view the data at this point. Do you have any tips to only add CRUD capabilities to Angular-Django?

Thank in advance!

POST http://localhost:8001/api-token-auth/ 401

This is issue of staled djangotoken in cookies.

When i am going to django-admin, deleting Token, and creating new - old token still presented in browser cookies, thou "class ObtainAuthToken(APIView):" prevents access to .post() method, coz old token is now invalid.

When app receives 401 from /api-token-auth/ it must clear cookies (clear djangotoken) and try again

or it is of existing sessionId