简体   繁体   中英

Request Headers not found when sending requests to Heroku PHP API

First time Heroku user!

My php api has a authentication method for an iOS app:

public function authenticateAppKey() {
    if (!isset($_SERVER['HTTP_APP_KEY'])) {
        error('App Key Not Supplied');
        exit;
    } else if ($_SERVER['HTTP_APP_KEY'] != self::$api_key) {
        error('App Key Incorrect');
        exit;
    }
}

It is always returning App Key Not Supplied

This has always worked up until I have switched to Heroku, wondering if I have missed a setting during the Heroku setup.

These are my build packs:

在此处输入图片说明

I also have https://github.com/travstoll/heroku-buildpack-php installed on the server

Deployment Log if helpful:

-----> Using set buildpack heroku/php
-----> PHP app detected
-----> Bootstrapping...
-----> Installing platform packages...
       NOTICE: No runtime required in composer.lock; using PHP ^5.5.17
       - apache (2.4.18)
       - nginx (1.8.1)
       - php (5.6.19)
-----> Installing dependencies...
       Composer version 1.0.0-beta1 2016-03-03 15:15:10
-----> Preparing runtime environment...
       NOTICE: No Procfile, using 'web: vendor/bin/heroku-php-apache2'.
-----> Checking for additional extensions to install...
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 13M
-----> Launching...
       Released v43
       https://<address>.herokuapp.com/ deployed to Heroku

OK found the issue and fixed.

It seems that request header variables should not have underscores in them. This has only been highlighted since moving to Heroku.

So in my situation APP_KEY was not visible to the code, changed to APPKEY and everything was fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM