title: Nginx configuration with Laravel API + vuejs
body: <p>I have the application with frontend on vuejs which works through the laravel api on backend. And I use Laravel Passport for authorization.
  When I start the application through the integrated laravel web server (artisan serve) on localhost:8000 it works good without any errors.
  But when I moved it to my local web server I got some problems.</p>
  
  <p>When I try to do the post request</p>
  
  <pre><code>axios.post('http://project.local/oauth/token', data)
  </code></pre>
  
  <p>I get the http error <strong>405 (Method Not Allowed)</strong>.
  I excluded all routes from CSRF-token, added CORS headers and anyway it doesnt work. As I said on localhost:8000 it works well.</p>
  
  <p>I didn't find any information about this problem and couldn't do it by myself. Does anyone know anything about it? Thanks in advance.</p>
  
  <p>My nginx config</p>
  
  <pre><code>    server {
      listen  80;
  
      root /home/me/project/frontend/dist;
      index index.html index.php;
      server_name project.local;
  
      access_log off;
      error_log /home/me/project/backend/error.log notice;
  
      location / {
      index index.html;
              try_files $uri $uri/ /index.html?$args;
      }
  
      location /api/v1 {
           root /home/me/project/backend/public;
           rewrite ^/api/v1/(.*)$ /$1 break;
           try_files $uri $uri/ /index.php?$query_string;
      }
  
      location /oauth/token {
          root /home/me/project/backend/public;
          rewrite ^/oauth/token/(.*)$ /$1 break;
          try_files $uri $uri/ /index.php?$query_string;
      }
  
      location ~ \.php$ {
  
              set $newurl $request_uri;
              if ($newurl ~ ^/api/v1(.*)$) {
                  set $newurl $1;
                  root /home/me/project/backend/public;
              }
  
              if ($newurl ~ ^/oauth/token(.*)$) {
                  set $newurl $1;
                  root /home/me/project/backend/public;
              }
  
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
              fastcgi_index index.php;
              include fastcgi_params;
              fastcgi_param REQUEST_URI $newurl;
              fastcgi_param SCRIPT_FILENAME 
          $document_root$fastcgi_script_name;
          fastcgi_intercept_errors off;
          fastcgi_buffer_size 16k;
          fastcgi_buffers 4 16k;
      }
      location ~ /\.ht {
              deny all;
      }
  }
  </code></pre>