Mojolicious doesn't grab url (base url only)

I created a simple API using mojolicious

, but I just switched from Apache to Nginx

and can't figure out how to properly handle the url.

Here is my server config file

server {
    listen 80;
    listen [::]:80;
    root /var/www/example.com/public_html;
    index index.pl index.html index.htm index.nginx-debian.html;

    server_name example.com www.example.com;

    location / {
            gzip off;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass  127.0.0.1:8090;
            fastcgi_param SCRIPT_FILENAME /var/www/example/public_html/$fastcgi_script_name;
        }
}

      

It gets processed mojolicious

, but I get the following result.

Method: GET
URL:    
Base URL: http://example.com/clients/

      

As you can see, the base url is fixed, but the url is empty.

My pattern

Pattern Methods Name
/clients GET clients

      

What's wrong? How can I handle requests correctly?

+3


source to share


1 answer


I faced the same problem. I found the following solution.

app->hook(before_dispatch => sub {
        my $c = shift;
        $c->tx->req->url->path->{'path'} = @{$c->tx->req->env}{'REQUEST_URI'};
    });
app->start;

      



It's a quick and dirty solution, but it works.

Hope it helps.

+3


source







All Articles