0

So I have two directories. One for angular and one for laravel. I am trying to deploy them on the same server (LEMP stack).

This is my nginx conf:

server {
    listen 80 default_server;

    charset utf-8;

    location / {
        root /var/www/client/;
        index index.html;

        try_files $uri $uri/ /index.html;
    }

    location /api {
        alias /var/www/server/public/;
        index index.php;

        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

Angular works fine. The website is shown but when I make requests to /api I just get "not found". For example /api/register doesnt work. What am I doing wrong?

1 Answer 1

0

Might be duplicate issue

Add this statement after "fastcgi_param"

fastcgi_param  REQUEST_URI        $request_uri;

Laravel uses $_SERVER['REQUEST_URI'] variable to route and it is passed to Laravel from fastcgi.

Ref : Laravel + AngularJS Nginx routing

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

Comments

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.