Skip to content

Vite proxy doesnt work with api request to a local server running in docker #9285

Answered by sapphi-red
koval96 asked this question in Q&A
Discussion options

You must be logged in to vote

server.proxy proxies request from Vite to the target. So you should request to Vite server.

import axios from 'axios'

export const getConfigs = async () => {
  try {
    console.log(await axios.get("/api/v1/configurations")) // "http://localhost:3000/api/v1/configurations"
  } catch (e) {
    console.log(e)
  }
}

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@koval96
Comment options

@mladen-orsolic
Comment options

Answer selected by koval96
Comment options

You must be logged in to vote
5 replies
@v-kazantsev
Comment options

@andres-dos-santos
Comment options

@matias-gmg
Comment options

@lequoctrung-it
Comment options

@sudhir4ev
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
9 participants