How can I redirect an API endpoint?

My website is https://main--effervescent-genie-c96f59.netlify.app/.

I’m trying to deploy the website with an endpoint that has a proxy being used. In my package.json I have a "proxy": "https://en.wikipedia.org/w".

I did this to remove the CORS policy error which I was getting.

With Axios, I’m fetching data like this:

const searchImageSourceURL = `/api.php?action=query&titles=${finalURL}&prop=pageimages&format=json&pithumbsize=400`;
const res2 = await axios.get(searchImageSourceURL);

The problem is that my Netlify website is returning "Failed to load resource: the server responded with a status of 404 () - /api.php?action=query&titles=Lance_Stroll&prop=pageimages&format=json&pithumbsize=400:1"

How can I deploy my website but still be able to use this proxy because of CORS?

Hi @guilhermxlopes

Check out the Proxy to another service section of the rewrite and proxies documentation.