Skip to content

Commit

Permalink
update:vite开发环境跨域配置以及index.html说明文字
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanningHan committed Sep 24, 2020
1 parent d6794ab commit 404d8df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions micro-juejin-tryVite/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<title>Vite App</title>
</head>
<body>
<br></br>
<br></br>
<h1>翻车了</h1>
<h2>entryjs被import-html-entry替换成了text/javascript类型的script标签</h2>
<h2> 而vite开发环境下是module类型的,束手无策┓( ´∀` )┏</h2>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
Expand Down
9 changes: 8 additions & 1 deletion micro-juejin-tryVite/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,12 @@ export default {
changeOrigin: true,
rewrite: path => path.replace(/^\/api\/micro-juejin-tryVite/, '/api')
}
},
configureServer: ctx => {
ctx.app.use(async (ctx,next) => {
ctx.set('Access-Control-Allow-Origin', '*')
await next()
})
}
}
}

0 comments on commit 404d8df

Please sign in to comment.