PHP与Vue CLI如何设置Vue.config.js



尝试将PHP与Vue CLI一起使用,我正在尝试复制这一点:https://forum.vuejs.org/t/using-php-with-vue-cli/52842/3但失败了。

我有这样的文件夹结构:

  1. myapp/

    • 公共/
    • src/
    • vue.config.js
  2. 背面/

    • index.php

当我从myapp/运行npm run serve时,我会转到http://localhost:8080并查看我的应用程序。

在另一个名为"back"的文件夹中,我有我的php文件。我使用mamp运行服务器,并访问以下地址的此文件夹:http://back:8888

在我的vue.config.js中,我有

module.exports = {
devServer: {
proxy: {
'^/api': {
target: 'http://back:8888',
changeOrigin: true,
logLevel: "debug"
}
}
}
};

据我所知,当我转到http://localhost:8080/api和http://back:8888.

但我没有,我得了404分http://localhost:8080/api,然后返回:8888可以。

在终端中,我有这个[HPM] GET /api -> http://back:8888所以它确实检测到重定向。

最奇怪的是:

module.exports = {
devServer: {
proxy: {
'^/api': {
target: 'http://back:8888/index.php',
changeOrigin: true,
logLevel: "debug"
}
}
}
};

当我访问localhost:8080/api时,我的后台文件夹中确实有index.php的输出。

我在这里错过了什么?

感谢

我添加了miss-readhttps://forum.vuejs.org/t/using-php-with-vue-cli/52842/3.

localhost:8080/api==http://back:8888/api,但与我不同:localhost:8080/api==http://back:8888.

最新更新