Question

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

Posted October 12, 2020 106 views
ApacheVue.jsLaravel

I would like to host my nuxt app which has 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.

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!