The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

can't read headers in angularJS

zin's Avatar


19 Feb, 2016 07:29 AM

in Slim

$app->hook('slim.before.dispatch', function () use ($app) {
    global $request,$app;
    if ($request->headers->get('Auth-Token') !== "556DARARVV875LJ") {
        $app->halt(403, "missing token");
$app->get('/person', 'getPersons');
function getPersons() {
    try {
        $db = getConnection();
        $stmt = $db->query('select * from person');
        $data = $stmt->fetchAll(PDO::FETCH_OBJ);
        echo json_encode($data);
    } catch (PDOException $e) {
        echo $e . getMessage();
in Angular
$http.get("http://localhost/rest/person", {
    headers: {
            'Auth-Token': '556DARARVV875LJ'
error in console XMLHttpRequest cannot load http://localhost/rest/person. Response for preflight has invalid HTTP status code 404
  1. 1 Posted by Qiniso on 19 Feb, 2016 09:29 AM

    Qiniso's Avatar

    Hi zin,

    First check what headers are you getting.

    Also, is there a reason you're using global $request,$app;?

    Also why $app in the use ($app)"andglobal` at the same time

  2. 2 Posted by Johan on 19 Feb, 2016 01:54 PM

    Johan's Avatar

    is your index.php located in the rest/ directory of the root of your website?

    can you share the directory structure of your project?

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac