# koa-server **Repository Path**: cynx/koa-server ## Basic Information - **Project Name**: koa-server - **Description**: 解决生产环境跨域问题,支持history模式 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-07-11 - **Last Updated**: 2021-07-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README `yarn start` > 静态托管中间件在最后处理 + 打包前修改生成环境的baseURL `.env.production` ```js VUE_APP_BASE_API = '/api' ``` + 如果`/api`不是所有接口都包含的路径,打开注释的重写即可。 + 将打包后dist文件夹中文件放到public文件夹中,启动koa服务即可。 + `history`模式设置: 创建路由实例时配置。例: ```js // 创建路由实例 const createRouter = () => new Router({ mode: 'history', // require service support scrollBehavior: () => ({ y: 0 }), // 指定路由规则 routes: [ ...constantRoutes // 静态路由, 首页 ] }) ```