1

I have a vue web app where you can upload images. When I was creating it, I was running it on localhost with hot-reload on.

However, when I hosted my app at digitalocean and used this command (npm run build) I faced a problem. As far as I understand it, vue had built my app, and then started ignoring new files.

I've already tried to put the uploads folder outside of vue app but it didn't help me.

How to upload images and dynamically be able to access them?

By the way my stack is: Vue.js (frontend), Laravel (backend) and nginx.

Tyoma Inagamov
  • 125
  • 4
  • 13

1 Answers1

0

The Vue frontend has to be built (creating a "dist" folder) every time you wish to see a change.

Either host the images on your DigitalOcean droplet or a database.

Simple way to accomplish self-hosting of the images with 2 APIs (POST, GET):

1. Send image frontend -> backend

2. Save image backend -> droplet (parse the image with Laravel and save to a directory on your server)

3. Send image backend -> frontend OR use image's location on the server as your "src" (whichever method is necessary in your app)


Or serve your images using nginx: How to serve images with nginx

thmspl
  • 2,437
  • 3
  • 22
  • 48
kuntervert
  • 86
  • 1
  • 9