Report this

What is the reason for this report?

Laravel & Nuxt hosted on vps - same domain how to access laravel storage and api?

Posted on October 12, 2020

Hello,

I would like to host my nuxt app which has a Laravel backend on my VPS. I have done it and it works but when I have my .conf file for domain setup like this:

    <IfModule mod_ssl.c>
<VirtualHost *:80>
ServerName xxxxxxxxx
Redirect permanent / https://xxxxxxxxx/
</VirtualHost>
<VirtualHost *:443>
    ServerName xxxxxxxxx
    ServerAlias www.xxxxxxxxx
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/htmlxxxxxxxxx/public

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # has Nuxt runs on port 3000
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    RewriteEngine on

    <Directory /var/www/html/xxxxxxxxx/public/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/livexxxxxxxxx-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxxxxxxx-0001/privkey.pem
</VirtualHost>
</IfModule>

The nuxt app works and server-side rendering is enabled but none of my api calls on my domain work.

That could be solved by api subdomain but how can I access my laravel files stored in /storage?

I have run php artisan storage:link but I cannot get the files to show because the nuxt server is I believe kill request to the laravel part.

Can anybody help, please?

Thank you.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.