Ayane
Ayane

Reputation: 473

Error while deploying my Spring Angular2 application in Heroku

I have built a spring application with angular 2 for the front end and a cloud hosted database at mlab. It works perfectly fine on development enviroment but now I'm trying to deploy it in Heroku. I've managed to do so but it doesn't seem to be receiving data needed from the database.

This is the error that appears in console:

Mixed Content: The page at 'https://myappname.herokuapp.com/list' was loaded over HTTPS,
but requested an insecure XMLHttpRequest endpoint 'http://myappname.herokuapp.com/security/login'.
This request has been blocked; the content must be served over HTTPS.

I have tried to redirect my urls to the https equivalent as shown in this post Angular 2+Heroku , always redirect to https:// instead of using http:// but it didn't work.

http://myappname.herokuapp.com/security/login is the url where you are redirected when spring security intercepts a request when you have no access to a resource so maybe the problem is there? Do I have to change the spring security config file for deployment or is it something else?.

Upvotes: 1

Views: 696

Answers (1)

Ayane
Ayane

Reputation: 473

After looking around a little more I found this post which gives a solution to my problem: http://www.learningthegoodstuff.com/2015/08/mixed-http-error-with-spring-security.html

All the details are explained there, basically all I had to do was add this two lines to my application.properties file:

server.tomcat.remote_ip_header=x-forwarded-for
server.tomcat.protocol_header=x-forwarded-proto

Upvotes: 1

Related Questions