赞
踩
- import { fileURLToPath, URL } from 'node:url'
-
- import { defineConfig } from 'vite'
- import vue from '@vitejs/plugin-vue'
-
- // https://vitejs.dev/config/
- export default defineConfig({
- plugins: [vue()],
- resolve: {
- alias: {
- '@': fileURLToPath(new URL('./src', import.meta.url))
- }
- },
- server:{
- proxy: {
- '/api': {
- target: "https://voice.baidu.com/api/newpneumonia",
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/api/, '')
- }
- }
- }
- })
target:要请求的网址
如果只是使用当前的网址那么url就为:/api
- axios({
- url:'/api',
- method:'get'
- }).then((res)=>{
- console.log(res.data);
- })
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。