Hi,
I have a really annoying problem that I cannot resolve. I have a
Mojolicious (full) app running behind Apache (using mod_proxy path), when I
make an ajax call to my app for data the payload contains header data and
is not recognised as json, for example:
Response payload
*HTTP/1.1 N Content-Type: application/json;charset=UTF-8Content-Length:
20Server: Mojolicious (Perl)Date: Wed, 25 Apr 2018 14:14:50 GMT*
{"foo":[1,"test",3]}
The payload response is fine if I access the app directly (not via Apache).
My Apache config:
<Proxy *>
Require all granted
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /app http://localhost:8080/app
ProxyPassReverse /app http://localhost:8080/app
ProxyPreserveHost On
RequestHeader set X-Forwarded-HTTPS "0"
In app startup:
$self->log->level('debug');
$self->hook('before_dispatch' => sub {
my $self = shift;
if ($self->req->headers->header('X-Forwarded-Host')) {
#Proxy Path setting
my $path = shift @{$self->req->url->path->parts};
push @{$self->req->url->base->path->parts}, $path;
}
});
route
$r->get('/data/:status')->to('controller#action', status => 'N');
controller
sub action
{
my $self = shift;
$self->render(json => {foo => [1, 'test', 3]});
}
I know this may not be directly realted to Mojolicious but can anyone see
what I'm doing wrong?
MJ
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.