A simple way to avoid CORS trouble in your external downloads.
This is a solution to a (highly specific) problem i've had with NuxtJS v2, this being trying to get the server to serve me an external server's files as a download, while avoiding the CORS hijinks you'd run into with most solutions.
It's honestly pretty boilerplate stuff to get this demo working.
You only need NPM, any other stuff you might need you can get it through npm install.
- Clone the repo
git clone https://github.com/maximoospital/download-proxy.git
- Install NPM packages
npm install
- Run it.
npm run dev
The way this works is pretty simple actually, the path /downloadImage is now assigned to the server middleware script ~/server-middleware/downloadImage.js, the way you can utilize this is by calling the path itself as /downloadImage/?url="YOUR LINK HERE" (without the quotation marks). Keep in mind, the way this avoids CORS is by proxying traffic itself through the NodeJS server, so it is meant for either light files like images or light traffic, it does cleanup after download.
- Maximo Ospital - Junior Developer and CS Student - Maximo Ospital - i made this lol