My api is returning http links even though my requests are coming in over https. When my client relies on these links it's creating mixed content warnings.
How can I tell jsonapi-resources to build relationship links with the https protocol?
It looks like ActAsResourceController#base_url is supposed to rely on the current request's protocol. However, when debugging, it looks like this method isn't always called when constructing my resource responses.
Thoughts?
+1, ran into this as well...
Update: I had some (shame on me) code in my application controller that caused this, to handle local Ember requests. When I altered this code to :
def base_url
if Rails.env.development?
@base_url = "http://localhost:4200"
else
@base_url ||= request.protocol + request.host_with_port
end
@base_url
end
The problem was solved, so I suspect something similar was the cause.
Nice, thanks for the feedback. I'll double check that I'm not overriding this method.
Had the same problem, for me it was because of request.protocol not being read correctly due to nginx, missing the proxy_set_header X-Forwarded-Proto https; in its config, added that and it was working like it should.
@Jeroen Thanks for the tip! It sounds like that might be my issue too! Good
thinking, I'll check this week.
On Sun, Nov 8, 2015 at 12:21 PM, Jeroen K. [email protected] wrote:
Had the same problem, for me it was because of request.protocol not being
read correctly due to nginx, missing the proxy_set_header
X-Forwarded-Proto https; in its config, added that and it was working
like it should.—
Reply to this email directly or view it on GitHub
https://github.com/cerebris/jsonapi-resources/issues/501#issuecomment-154842306
.
@thedeeno: Did that solve your issue? I'm going to be setting up HTTPS for my app in a few weeks, hoping to avoid this issue.
@jrnk 's solution worked for me. I was just missing the nginx X-Forwarded-Proto line in my nginx config.
Most helpful comment
Had the same problem, for me it was because of
request.protocolnot being read correctly due to nginx, missing theproxy_set_header X-Forwarded-Proto https;in its config, added that and it was working like it should.