Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Heroku上的Nuxt为API调用返回404,但在本地运行良好_Node.js_Vue.js_Heroku_Nuxt.js - Fatal编程技术网

Node.js Heroku上的Nuxt为API调用返回404,但在本地运行良好

Node.js Heroku上的Nuxt为API调用返回404,但在本地运行良好,node.js,vue.js,heroku,nuxt.js,Node.js,Vue.js,Heroku,Nuxt.js,对myapp.herokuapp.com/api/test的任何axios或postman调用都将返回404,但对localhost:3000/api/test的调用将返回预期值。我已经用头撞了好几个小时了,怎么了?我的项目结构如下: 这是我的nuxt配置: const pkg = require("./package"); module.exports = { mode: "universal", head: { title: "My app",

myapp.herokuapp.com/api/test
的任何axios或postman调用都将返回404,但对
localhost:3000/api/test
的调用将返回预期值。我已经用头撞了好几个小时了,怎么了?我的项目结构如下:

这是我的nuxt配置:

const pkg = require("./package");

module.exports = {
    mode: "universal",

    head: {
        title: "My app",
        meta: [
            { ...
            },
            { ...
            },
            { ...
            },
            { ...
            }
        ],
        link: [
            { ...
            },
            { ...
            },
            { ...
            }
        ],
        script: [ ...
        ]
    },

    /*
     ** Nuxt.js modules
     */
    modules: [
        [
            "@nuxtjs/axios",
            {
                baseURL: process.env.API_URL || "http://localhost:3000/"
            }
        ],
        "bootstrap-vue/nuxt",
    ],

    router: {
        scrollBehavior: async (to, from, savedPosition) => {
            if (savedPosition) {
                return savedPosition;
            }

            const findEl = async (hash, x) => {
                return ( ...
                );
            };

            if (to.hash) {
                let el = await findEl(to.hash);

                if (el) { ...
                }
            }

            return { ... };
        }
    },

    /*
     ** Build configuration
     */
    build: {
        optimization: { ... 
        },
        analyze: false
    }
};

如果你能帮我,我将不胜感激,我不知道该怎么办。为什么应用程序在本地运行时访问api没有问题,但在heroku上运行时会抛出404?我试图找到所有可能的终点,我可以想到与邮递员,但没有任何工作。它只在本地工作。

你为什么要创建多个帖子?请随便回答。你明白了吗?