构建后无法将 react 前端连接到后端 [关闭]

Cant connect react frontend to backend after build [closed]

提问人:Wasif Hussain 提问时间:11/16/2023 最后编辑:VLAZWasif Hussain 更新时间:11/16/2023 访问量:17

问:


想改进这个问题吗?通过编辑这篇文章添加详细信息并澄清问题。

6天前关闭。

我的 vite.config.js ,我已经使用 chatgpt 添加了构建部分,但我认为它不起作用

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
    plugins: [react()],
    server: {
        port: 3000,
        // Get rid of the CORS error
        proxy: {
            "/api": {
                target: "https://threads-backend-kzv5.onrender.com",
                changeOrigin: true,
                secure: true,
            },
        },
    },
    build: {
        target: "esnext", // or "esnext" if your environment supports it
        polyfillDynamicImport: false, // disable dynamic import polyfill
    },
});

ReactJS 节点.js

评论


答: 暂无答案