【问题标题】:Angular call to PHP returns 404 after Grunt build在 Grunt 构建后,对 PHP 的 Angular 调用返回 404
【发布时间】:2015-02-11 12:17:03
【问题描述】:

真的希望有人能指出我正确的方向,我迷路了 :D 构建我的第一个 ng-app,而 Grunt 构建导致找不到 api 调用 (php)。

文件夹结构是 dist->api->index.php,所以我不知道为什么调用返回 404。

我将 MAMP 作为服务器,调用看起来像是包含整个路径:http://disty:8888/api/testimonials

在开发中使用 grunt-serve,我使用了不同的端口而不是 MAMP,但据我所知,这与生产无关,对吧?

这可能没什么,但我非常希望学习。提前致谢!

【问题讨论】:

    标签: php angularjs gruntjs restful-url mamp-pro


    【解决方案1】:

    Grunt-serve 无法提供 PHP 文件,如果您想创建 PHP 服务器,请将 grunt-serve 替换为 grunt-php 并配置 baseport

    应该这样配置:

    grunt.initConfig({
    php: {
        dist: {
            options: {
                port: 8888,
                base: 'dist/api/',
                keepalive: true,
                open: true
            }
        }
    }
    });
    

    在此之后,您应该可以访问您的 index.php API。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-16
      • 1970-01-01
      • 1970-01-01
      • 2020-02-16
      • 1970-01-01
      • 2022-01-12
      • 1970-01-01
      • 2011-08-11
      相关资源
      最近更新 更多