Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnauthorizedError: No authorization token was found after building app (IE11) #1880

Closed
1 task done
whittssg opened this issue May 12, 2016 · 7 comments
Closed
1 task done

Comments

@whittssg
Copy link

whittssg commented May 12, 2016

  • I understand that GitHub issues are not for tech support, but for questions specific to this generator, bug reports, and feature requests.

Latest version of the stack.

Item Version
generator-angular-fullstack x.x.x
Node x.x.x
npm x.x.x
Operating System OS X 10 / Windows 10 / Ubuntu 15.10 / etc
etc etc
Item Answer
Transpiler Babel
Markup HTML
CSS CSS
Router ui-router
Build Tool Grunt
Client Tests Jasmine / Mocha
DB MongoDB
Auth Y

Hello, i finally put one of my apps into production (built) for testing and noticed that users cannot login when using IE 11..

I get the following error in the server console:

UnauthorizedError: No authorization token was found
    at middleware (C:\Apps\DataFusion\dist\node_modules\express-jwt\lib\index.js
:80:21)
    at Middleware_Common_Object.<anonymous> (C:\Apps\DataFusion\dist\server\auth
\auth.service.js:53:9)
    at next (C:\Apps\DataFusion\dist\node_modules\composable-middleware\lib\comp
osable-middleware.js:59:18)
    at Middleware_Common_Object.middleware (C:\Apps\DataFusion\dist\node_modules
\composable-middleware\lib\composable-middleware.js:76:7)
    at middleware (C:\Apps\DataFusion\dist\node_modules\composable-middleware\li
b\composable-middleware.js:31:25)
    at Layer.handle [as handle_request] (C:\Apps\DataFusion\dist\node_modules\ex
press\lib\router\layer.js:95:5)
    at next (C:\Apps\DataFusion\dist\node_modules\express\lib\router\route.js:13
1:13)
    at Route.dispatch (C:\Apps\DataFusion\dist\node_modules\express\lib\router\r
oute.js:112:3)
    at Layer.handle [as handle_request] (C:\Apps\DataFusion\dist\node_modules\ex
press\lib\router\layer.js:95:5)
    at C:\Apps\DataFusion\dist\node_modules\express\lib\router\index.js:277:22
    at Function.process_params (C:\Apps\DataFusion\dist\node_modules\express\lib
\router\index.js:330:12)
    at next (C:\Apps\DataFusion\dist\node_modules\express\lib\router\index.js:27
1:10)
    at Function.handle (C:\Apps\DataFusion\dist\node_modules\express\lib\router\
index.js:176:3)
    at router (C:\Apps\DataFusion\dist\node_modules\express\lib\router\index.js:
46:12)
    at Layer.handle [as handle_request] (C:\Apps\DataFusion\dist\node_modules\ex
press\lib\router\layer.js:95:5)
    at trim_prefix (C:\Apps\DataFusion\dist\node_modules\express\lib\router\inde
x.js:312:13)
    at C:\Apps\DataFusion\dist\node_modules\express\lib\router\index.js:280:7
    at Function.process_params (C:\Apps\DataFusion\dist\node_modules\express\lib
\router\index.js:330:12)
    at next (C:\Apps\DataFusion\dist\node_modules\express\lib\router\index.js:27
1:10)
    at logger (C:\Apps\DataFusion\dist\node_modules\morgan\index.js:144:5)
    at Layer.handle [as handle_request] (C:\Apps\DataFusion\dist\node_modules\ex
press\lib\router\layer.js:95:5)
    at trim_prefix (C:\Apps\DataFusion\dist\node_modules\express\lib\router\inde
x.js:312:13)
GET /api/users/me 401 1.228 ms - 13

I get this error after the user authorization has completed, after building the app and trying to log in with IE11. It works fine in Chrome.. and IE 11 works find when not running in prod (running grunt serve). So i am posting here before troubleshooting further to make sure its not a bug in the generator.

Thanks..

@Awk34
Copy link
Member

Awk34 commented May 13, 2016

Which version of the generator did you use? "Latest version of the stack." doesn't really help, especially if you're using a beta version or if someone looks at this issue in the future, once the generator version has been increased.

UnauthorizedError: No authorization token was found
You're sure that you ran the same steps and Chrome worked but IE11 failed? Was an auth token sent? If so, was it formatted properly?

@theodu60
Copy link

Hello,
I have the same problem :(
I think that the auth service is the cause.

@whittssg
Copy link
Author

I am using version 3.5.0 of the generator.

Yes i followed the exact same steps on IE, CHROME and FIREFOX.

Request Headers:

Key Value
Request POST /auth/local HTTP/1.1
Content-Type application/json;charset=utf-8
Accept application/json, text/plain, /
X-XSRF-TOKEN D3mmAK4GKQ2skbcea0st0y0Z7hSjfLW9OrtUQ=
Referer http://mydomain.com/login
Accept-Language en-US
Accept-Encoding gzip, deflate
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host mydomain.com
Content-Length 69
Connection Keep-Alive
Cache-Control no-cache
Cookie _ga=GA1.2.1036502328.1449502252; _mkto_trk=id:565-YXD-236&token:_mch-carefusion.com-1449502252339-27679; _ga=GA1.3.1036502328.1449502252; _gat=1; XSRF-TOKEN=D3mmAK4GKQ2skbcea0st0y0Z7hSjfLW9OrtUQ%3D; connect.sid=s%3AWZwZ1_j3u6hXYa2q4NqcTF_trnvOrdwq.MbWVMvBRnPKG1I6zPMGa5ta0xGl2QsE3wQm6ROZIdFk

Reponse Headers:

Key Value
Response HTTP/1.1 200 OK
Server nginx/1.9.15
Date Fri, 13 May 2016 12:45:49 GMT
Content-Type application/json; charset=utf-8
Content-Length 204
Connection keep-alive
X-Powered-By Express
Vary X-HTTP-Method-Override, Accept-Encoding
X-XSS-Protection 1; mode=block
X-FRAME-OPTIONS SAMEORIGIN
Strict-Transport-Security max-age=31536000; includeSubDomains; preload
Set-Cookie XSRF-TOKEN=zNexgXQ1XeOAj61M%2BEiCGgDkz0HjLN9oY3xho%3D; Path=/
ETag W/"cc-IXmz5yFM5IXoJcTr8kiUzw"

Response Body

{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1NzMzOGIyZDI1MWVkNDQwMDE5OTA1NTkiLCJyb2xlIjoiYWRtaW4iLCJpYXQiOjE0NjMxNDM1NDksImV4cCI6MTQ2MzE2MTU0OX0.OYTxD2CEHhIX9YObRboM_wqyE8Ps07N_wh6z9Uy211g"}

When i pulled this info i was running it on port 9000 with NGINX as a proxy but it does the same thing when running it directly on port 80 without NGINX.

Thanks,

@erikrenberg
Copy link
Contributor

I have the same problem, when the port number is 80 or 443..

The following fix solved the issue for me with other port numbers, such as 9000: #1523

However with port 80 or 443 it doesn't work: The problems seems to be in isSameOrigin() in util.service.js: Internet Explorer (11 which I'm testing) doesn't set $window.location.port to 80 but to "". $window.location is pushed to the origins vector and then filtered with the port number of url (which is 80) in isSameOrigin() and they don't match.

Here's the util.service.js file: https://github.com/angular-fullstack/generator-angular-fullstack/blob/master/templates/app/client/components/util/util.service.js

I'm not sure how to fix it, I can of course avoid filtering if the port is "" but that seems like an ugly fix....

@Awk34
Copy link
Member

Awk34 commented May 13, 2016

@whittssg okay it's useful to know that you're using 3.5.0, because that indeed is not the latest version.

Ugh, IE is such a pain in the ass. @erikrenberg I think that that fix would be fine, with a comment with a link to the IE bug. Do you want to make a PR?

@whittssg
Copy link
Author

@Awk34 Sorry about that.. could of sworn i updated a week ago or so. to get it to work for now i just commented out the port check

return url.hostname === o.hostname &&
                            /*url.port === o.port &&*/
                            url.protocol === o.protocol;

erikrenberg added a commit to erikrenberg/generator-angular-fullstack that referenced this issue May 16, 2016
Fixes logging in with IE11 when using well-known port numbers 80 and 443 where otherwise isSameOrigin() fails because of an IE bug. See issue angular-fullstack#1880
@Awk34 Awk34 closed this as completed in 414b80a May 25, 2016
@Cdvalencia
Copy link

Hi.
here is the solution: https://stackoverflow.com/a/35964735/4996446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants