본문 바로가기

카테고리 없음

vue proxy 404 error

vue 에서 외부 json 을 참조하기 위해서 단순한 생각에 호출했는데 (json 은 예전에 그냥되었던 기억에?)

CORS 오류가 발생한다. -_ -?

여기 저기 뒤저보고 proxy 설정하고 사용하면 된다고 해서 했는데 

404 Not Found 오류가 발생한다. -_ - ????

다시 여기 저기 뒤져보니 음 pathRewrite 를 하면 된다고 해서 설정하니 된다. 

https://stackoverflow.com/questions/54216516/devserver-proxy-in-config-throws-404

 

devServer proxy in config throws 404

I have this in src/vue.config.js module.exports = { devServer: { proxy: { '/api': { target: 'http://localhost:8081', changeOrigin: true, }, }, }, }; and I'm

stackoverflow.com

vue.config.ts

module.exports = {
  devServer: {
    port: 8080,
    proxy: {
      '/test': {
        target: 'https://metadata-store.klaytnapi.com',
        changeOrigin: true,
        ws: true,
        pathRewrite: { '^/test': '/'},
      },
  },
} }

axios get

api.get('/test/e83b36ac-9050-e1de-9c30-004cea9aac87/f6f20c09-fb74-b266-af5a-7638e5c9184b.json')
  .then((res) => {
    console.log(res);
  })
  .catch((e) => console.error(e));

 

머든 안 해본일에는 찾는게 일이군