[Vuejs]-Heroku Deploy Vite Static App Won't Connect to API with Axios Using a Proxy

0๐Ÿ‘

I found it: for anyone else having trouble with this kind of deployment on Heroku โ€” the mountpoint "/1.0/address" in static.json seems to be replaced resulting in the 404 not found.

For production I added a prefix /api in my axios call, something like

var apiPath = '/1.0/address/find?country=at&zip=' + zip + '&city=' + city + '&street-address=' + street + '&street-number=&offset=1&limit=100'
        var prodMountpoint = '/api' // /api/
        if (import.meta.env.PROD) {
            apiPath = prodMountpoint + apiPath
        }

This results in a correct api call: "/api" is replaced with the proxied host, if I understand correctly. For development, the vite.config.js does its work as before.

Leave a comment