skip to Main Content

Where to store images that are added to the application after the build? In nuxt2 I used the /static folder for this. I uploaded images there and from there I took them for the frontend. But in nuxt3 folder /public, no longer works as well. After the build everything copies to .otput/…

2

Answers


  1. you can do one of the following:

    1. serve public folder directly from hosting environment and contiue uploading the images to it after the build
    2. set up a middleware to serve images from a directory where images are uploaded after the build
    3. external storage like s3 or any type of static file server
    Login or Signup to reply.
  2. i used nginx and did the following setup for statically generated site:

    server {
        listen 80;
        server_name yourdomain.com;
    
        # Root directory for the generated static site
        root /var/www/your-nuxt-app/.output/public;
    
        # Serve static files directly
        location / {
            try_files $uri $uri/ /index.html;
        }
    
        # Serve the /public directory directly if you upload additional files
        location /public/ {
            alias /var/www/your-nuxt-app/public/;
            access_log off;
            expires max;
        }
    }
    
    
    

    if you are using SSR then we need to tweak the nginx config file a little as the app should be served with pm2 and proxy pass it to nginx.let me know if you need that.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search