M
M
MynameIsBoxyy2021-06-01 16:30:41
Laravel
MynameIsBoxyy, 2021-06-01 16:30:41

How to connect laravel and nuxt?

Hello. It's probably a simple question, but I can't figure it out. You need to connect laravel and nuxtjs. Laravel as api. Write solutions. As I understand it, Laravel can be moved to a separate domain, but I don’t like it that way. Are there any other options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-06-01
@MynameIsBoxyy

In my case, the nginx + apache + nodejs, laravel + vue bundle works (only I don’t have nuxt, but quasar, but this doesn’t change the essence).
Apache configured host on port :8080

<VirtualHost *:8080>
  DocumentRoot    "d:/dev/projects/wofh-tools/wofh-tools.project/public"
  ServerName      "wofh-tools.project"
  ServerAlias     "wofh-tools.project" 
  SetEnvIfNoCase X-Forwarded-Proto https HTTPS=on
</VirtualHost>

Under the node, an express server is raised on port: 3333, on which the vue ssr project is running.
Nginx listens on standard ports
AND proxies normal requests to the nodejs server, api requests and some others (to storage statics, to the admin panel, etc.) - to apache/php
server {
    listen         127.0.0.1:80;
    listen         127.0.0.1:443 ssl;
    server_name    wofh-tools.project ;

    ssl_certificate               "d:/openserver/userdata/config/cert_files/server.crt";
    ssl_certificate_key           "d:/openserver/userdata/config/cert_files/server.key";
    location ~ /\. {deny all;}
    location / {
        proxy_buffer_size         64k;
        proxy_buffering           on;
        proxy_buffers             4 64k;
        proxy_connect_timeout     5s;
        proxy_ignore_client_abort off;
        proxy_intercept_errors    off;
        proxy_pass                http://127.0.0.1:3333;
        proxy_pass_header         Server;
        proxy_read_timeout        5m;
        proxy_redirect            off;
        proxy_send_timeout        5m;
        proxy_set_header          Host $host;
        proxy_set_header          X-Forwarded-For $http_x_forwarded_for;
        proxy_set_header          X-Real-IP $remote_addr;
        proxy_set_header          X-Forwarded-Proto $scheme;
    }
    location /api {
        proxy_pass                http://wofh-tools.project:8080/api;
        proxy_set_header          Host $host;
        proxy_set_header          X-Real-IP $remote_addr;
        proxy_set_header          X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /admin {
        proxy_pass                http://wofh-tools.project:8080/admin;
        proxy_set_header          Host $host;
        proxy_set_header          X-Real-IP $remote_addr;
    }
    location /tracy {
        proxy_pass                http://wofh-tools.project:8080/tracy;
        proxy_set_header          Host $host;
        proxy_set_header          X-Real-IP $remote_addr;
    }
    location /vendor {
        proxy_pass                http://wofh-tools.project:8080/vendor;
        proxy_set_header          Host $host;
        proxy_set_header          X-Real-IP $remote_addr;
    }
    location /storage {
        proxy_pass                http://wofh-tools.project:8080/storage;
        proxy_set_header          Host $host;
        proxy_set_header          X-Real-IP $remote_addr;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question