お世話になります。
どうかお助けください。
laravel9 + inertia.js+ vite + vue3環境で外部APIとの接続につきまして
そのまま接続しますとCORSエラーが発生するため、
viteのサーバオプションによりproxyを設定していますが、
proxyが効いていないのかlaravel側に接続しようとし、notofoundになってしまいます。
以下の設定をしておりますが、laravel側で他に設定する箇所などございますでしょうか?
どうかご教示願います。
viteサーバオプション
https://ja.vitejs.dev/config/server-options.html
送信
javascript
1<script setup> 2const searchAddress = async () => { 3 await axios 4 .get(`/api/search?zipcode=${form.zipcode}`) 5 .then((res) => { 6 console.log(res) 7 }) 8 .catch((error) => { 9 console.log(error) 10 }) 11 } 12</script>
vite.config.js
javascript
1export default defineConfig({ 2 server: { 3 proxy: { 4 '/api': { 5 target: "https://zipcloud.ibsnet.co.jp/api/", 6 changeOrigin: true, 7 secure: false, 8 rewrite: (path) => path.replace(/^\/api/, ""), 9 } 10 } 11 }

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。