1

I have written an app using the MEAN-stack(MongoDB, Express, AngularJS Node.js). Locally everything works as its supposed to but for some reason it behaves differently when I run it on Heroku.

The problem is that some of my angular controllers are transferred with the content type header text/html instead of application/javascript. As stated this is not a problem locally.

I have updated my npm and bower packages so everything should be up to date. Except for express where I use v. 3.4.4(because version 4.x.x requires a rewrite of the config). I use the same version of the frame works locally and on heroku.

Please let me know if I can provide any more information that would make it easier to solve the problem.

Regards

9
  • The URL of the app on Heroku might help... Commented Jul 30, 2014 at 10:30
  • Another difference in the environment is the load balancing in Heroku. devcenter.heroku.com/articles/http-routing though express should be consistent with the content types. It defaults to text/html when you set a string as the response. Commented Jul 30, 2014 at 18:33
  • When you say different behavior, what is exactly ? Not working at all ? Or simply some part of your code that is not working ? Commented Jul 30, 2014 at 19:46
  • @Aperçu : " A couple of my Controller is transferred as type text/html instead of application/javascript as most of the controllers are transferred as(the same files are transferred as app/js when I run it locally)." I suspect this breaks my code. Commented Jul 31, 2014 at 6:19
  • Make sure you are constructing your controllers to allow for minification. docs.angularjs.org/tutorial/step_05 Commented Aug 1, 2014 at 18:56

1 Answer 1

2

In most of the cases, when your scripts are transferred as text/html, it's because they are not found and return an HTML 404 page, you can check it using the Chrome Developer Tools in the Network tab.

When you have this issue, there is a lot of chance that your app is completely broken and that's why I ask you this.

Don't know if you're using some tasks runner like Grunt for your deployment process or just pushing your project as is but in both cases you need to check that the path of your files are correctly set by checking the requested url of yours scripts transferred with the wrong MIME TYPE.

Had also same problem with the Yeoman generator that was messing with the minification and file renaming some time ago.

Sign up to request clarification or add additional context in comments.

7 Comments

I have checked my Heroku log and all the files are found.
Could you please look at the content of these files ? Is it the right content with the wrong MIME TYPE ?
The content is wrong. It's HTML and not JavaScript.
Is the requested resource path corresponding to the effective file location in your deployed app ?
I'm referreing to theese files the same way I do with the others that are working and they are all at the same location.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.