Vue 3.2.13、Vite 3.2.5、vite-plugin-rewrite-all 1.0.1
托管在 IIS 上
我最近将我正在开发的应用程序部署到 IIS。我必须在我的构建中使用 --base 选项,因为我的网站是网站中的应用程序。
我的基本网址是https://example.com/myApplicaitons/myApp/vueRoute。
在初始加载时,我的 url 是https://example.com/myApplicaitons/myApp/vueRoute但当使用路由链接导航时,我成功加载了我的组件,但 url 是https://example.com/vueRoute而不是 https:// /example.com/myApplicaitons/myApp/vueRoute当我刷新时它会产生 404。
我已经在路由器中使用历史模式,甚至按照类似帖子中的建议安装了重写所有节点模块。我还有一个 web.config 公共文件夹,其配置与https://v3.router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations相同。
我将包括我的 vite.config.js、router/index.ts 和我的构建脚本。
vite.config.js
// Plugins
import vue from "@vitejs/plugin-vue";
import pluginRewriteAll from "vite-plugin-rewrite-all";
// Utilities
import { defineConfig } from "vite";
import { fileURLToPath, URL } from "node:url";
// eslint-disable-next-line no-undef
const path = require("path");
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), pluginRewriteAll()],
define: { "process.env": {} …
Run Code Online (Sandbox Code Playgroud)