Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

vue pathrewrite

作者:偶然\寥寂り   发布日期:2025-08-16   浏览:18

// vue.config.js

module.exports = {
  devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:4000', // 目标API服务器的基地址
        changeOrigin: true, // 是否改变请求origin
        pathRewrite: {
          '^/api': '' // 重写路径,将 /api 前缀去掉
        }
      }
    }
  }
};

// 解释说明:
// 上述代码配置了 Vue CLI 的开发服务器 (devServer) 的代理设置。当请求以 "/api" 开头时,
// 它会被代理到目标服务器 "http://localhost:4000"。同时,通过 pathRewrite 将请求路径中的 "/api" 前缀去掉。
// 例如,客户端请求 "/api/users" 会被代理为 "http://localhost:4000/users"。

上一篇:vue3 .sync

下一篇:vue 生成uuid

大家都在看

vue.config.js configu

node.js vue

vue 图表组件

vue3watch监听多个变量

vue查看版本

vue3 reactive对象重新赋值

vue等待几秒

vue3 setup computed

vue screenfull

vue json.stringify

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站