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

UglifyJS breaking HTTP request? Stripping "Authorization" header #243

Closed
praveenperera opened this Issue Mar 20, 2018 · 2 comments

Comments

2 participants
@praveenperera

praveenperera commented Mar 20, 2018

Is this a bug report?

MAYBE

Environment

  1. node -v: v8.9.4
  2. npm -v: 5.6.0
  3. yarn --version (if you use Yarn): 1.5.1
  4. npm ls create-elm-app -g (if you haven’t ejected):

I said maybe because this seems like a really weird bug that only I've experienced, but I thought I would create an issue in case anyone else runs across the same thing.

I ran into an interesting problem yesterday. On my dev environment authentication was working fine. However on production the “Authorization” header was not being sent. After hours of debug CORS and other related things, I decided to check out my webpack config.

From there I disabled the UglifyJS plugin and everything worked as expected. I doubled checked, enabling UglifyJS broke the HTTP request. I then undid all the other changes I made attempting to debug, and tried again. As far as I can tell, UglifyJS was the issue. I don’t know if this is relevant but I am using HttpBuilder to builder request.

I also tried enabling Uglify but setting dead_code to false. It still breaks it.

I don't know if this is a right place to post this, but I spent a lot of hours debugging this. I'm hoping opening this issue helps save someone else time if they run into the same or similar issue.

This was created by ejecting create-elm-app around May 21, 2017

Here is my webpack config, on line 219 you can see the UglifyJS plugin being commented out.

https://gist.github.com/praveenperera/f048f21eef1daef98a4c8f6cb834d2af

@halfzebra

This comment has been minimized.

Show comment
Hide comment
@halfzebra

halfzebra Mar 20, 2018

Owner

@praveenperera Thanks for reporting the issue!

The bug was caused by dead code elimination, which is disabled by default since v1.9.0

You can grab the latest config from webpack.config.prod.js if you want to upgrade.

Alternatively you can replace the configuration with:

 /* Minify the compiled JavaScript. */
 new UglifyJsPlugin({
   compress: {
     warnings: false,
   },
   output: {
     comments: false,
   },
 }), 

To get the JavaScript minification back for your project.

I hope this helps! I'm closing this issue, but please feel free to reopen it 👍

Owner

halfzebra commented Mar 20, 2018

@praveenperera Thanks for reporting the issue!

The bug was caused by dead code elimination, which is disabled by default since v1.9.0

You can grab the latest config from webpack.config.prod.js if you want to upgrade.

Alternatively you can replace the configuration with:

 /* Minify the compiled JavaScript. */
 new UglifyJsPlugin({
   compress: {
     warnings: false,
   },
   output: {
     comments: false,
   },
 }), 

To get the JavaScript minification back for your project.

I hope this helps! I'm closing this issue, but please feel free to reopen it 👍

@halfzebra halfzebra closed this Mar 20, 2018

@halfzebra halfzebra added the fix label Mar 20, 2018

@praveenperera

This comment has been minimized.

Show comment
Hide comment
@praveenperera

praveenperera Mar 20, 2018

@halfzebra ahh thanks! I thought I was disabling the dead_code elimination by setting dead_code: false. But removing the pure_funcs as above worked! Thanks

praveenperera commented Mar 20, 2018

@halfzebra ahh thanks! I thought I was disabling the dead_code elimination by setting dead_code: false. But removing the pure_funcs as above worked! Thanks

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