想請教各位一些問題:
在Debug下執行都是正常。
但前後端發佈後,架在IIS上
只有第一頁(Home)正常顯示,其餘(/Page1)都HTTP ERROR 404
請問有哪些地方沒有設定到嗎?
vite.config.js :
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import plugin from "@vitejs/plugin-vue";
import fs from "fs";
const baseFolder =
// eslint-disable-next-line no-undef
process.env.APPDATA !== undefined && process.env.APPDATA !== ""
// eslint-disable-next-line no-undef
? `${process.env.APPDATA}/ASP.NET/https`
// eslint-disable-next-line no-undef
: `${process.env.HOME}/.aspnet/https`;
// eslint-disable-next-line no-undef
const certificateArg = process.argv
.map((arg) => arg.match(/--name=(?<value>.+)/i))
.filter(Boolean)[0];
const certificateName = certificateArg ? certificateArg.groups.value : "vueapp";
if (!certificateName) {
console.error(
"Invalid certificate name. Run this script in the context of an npm/yarn script or pass --name=<<app>> explicitly."
);
// eslint-disable-next-line no-undef
process.exit(-1);
}
const certFilePath = path.join(baseFolder, `${certificateName}.pem`);
const keyFilePath = path.join(baseFolder, `${certificateName}.key`);
// https://vitejs.dev/config/
export default defineConfig({
plugins: [plugin()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
server: {
proxy: {
"^/weatherforecast": {
target: "https://localhost:7206/",
secure: false,
},
},
port: 5173,
https: {
key: fs.readFileSync(keyFilePath),
cert: fs.readFileSync(certFilePath),
},
},
});
router/index.js :
import { createRouter, createWebHistory } from "vue-router";
import Home from "@/components/Page/HomePage.vue";
import Page1 from "@/components/Page/Page1.vue";
export const router = createRouter({
history: createWebHistory(),
routes: [
{
path: "/",
component: Home,
},
{
path: "/Page1",
component: Page1,
},
],
});