apache2 OPTIONS HEADER

Alles, was den Apache betrifft, kann hier besprochen werden.

apache2 OPTIONS HEADER

Postby 11alex11 » 12. March 2018 21:42

Good evening together,
i have trouble with Apache2 and Laravel by sending a request with angular 5 HttpClient.

Guten Abend zusammen,
ich habe folgendes Problem mit Apache2 und Laravel. Beim Senden eines Post-Request mit Angular 5(HttpClient).

Folgendende Situation

The Laravel App run always with php artisan serve -host=0.0.0.0 on port 8000. And i can send my request for example over my local ip: 192.168.178.33

Die Laravel App lief immer unter php artisan serve -host=0.0.0.0 und dem Port 8000. Und ich konne meine Requests immer über die lokale Ip: 192.168.178.33 senden.

Für den Login habe ich folgende Url: http://192.168.178.33:8000/api/login

In den WebDev-Tools kann ich mir die Antwort ansehen.

Zuerst der OPTIONS HEADER und als zweite Antwort bekomme Ich die richtigen Werte aus dem Laravel Controller.
Code: Select all
    General
    Request URL:http://192.168.178.33:8000/api/login/
    Request Method:OPTIONS
    Status Code:200 OK
    Remote Address:192.168.178.33:8000
    Referrer Policy:no-referrer-when-downgrade

    Request Headers
    Accept:*/*
    Accept-Encoding:gzip, deflate
    Accept-Language:de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
    Access-Control-Request-Headers:content-type
    Access-Control-Request-Method:POST
    Connection:keep-alive
    Host:192.168.178.33:8000
    Origin:http://localhost:8100
    User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/64.0.3282.167 Chrome/64.0.3282.167 Safari/537.36


Zweite Antwort
Code: Select all
    General
    Request URL:http://192.168.178.33:8000/api/login/
    Request Method:POST
    Status Code:200 OK
    Remote Address:192.168.178.33:8000
    Referrer Policy:no-referrer-when-downgrade

    Request Headers
    Accept:application/json, text/plain, */*
    Accept-Encoding:gzip, deflate
    Accept-Language:de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
    Connection:keep-alive
    Content-Length:43
    Content-Type:application/json
    Host:192.168.178.33:8000
    Origin:http://localhost:8100
    Referer:http://localhost:8100/?ionicplatform=android&http://localhost:8100/ionic-lab&http://localhost:8100/ionic-lab
    User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/64.0.3282.167 Chrome/64.0.3282.167 Safari/537.36

    Request Payload
    {"email":"demo@demo.com","password":"test"}


So weit so gut, Wenn ich den selben Aufruf mache und den Server umstelle auf apache2 bekomme ich folgende Antwort 2 mal. URL: http://192.168.178.33/api/login

Code: Select all
    General
    Request URL:http://192.168.178.33/api/login/
    Request Method:OPTIONS
    Status Code:301 Moved Permanently
    Remote Address:192.168.178.33:80
    Referrer Policy:no-referrer-when-downgrade

    Request Headers
    Accept:*/*
    Accept-Encoding:gzip, deflate
    Accept-Language:de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
    Access-Control-Request-Headers:content-type
    Access-Control-Request-Method:POST
    Connection:keep-alive
    Host:192.168.178.33
    Origin:http://localhost:8100
    User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/64.0.3282.167 Chrome/64.0.3282.167 Safari/537.36


My Vhost
Code: Select all
    <VirtualHost *:80>
      ServerName localhost
     Documentroot /home/alexander/PhpstormProjects/restaurant/server/public

    <Directory "/home/alexander/PhpstormProjects/restaurant/server/public">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                Require all granted
    </Directory>

    </Virtualhost>


It's the only one enabled vhost

Versions
Code: Select all
    php -v
    PHP 7.0.25-0ubuntu0.16.04.1 (cli) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.25-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

    apache2 -v
    Server version: Apache/2.4.18 (Ubuntu)
    Server built:   2017-09-18T15:09:02

    php artisan -V
    Laravel Framework 5.5.37


For me it looks like that the request never reached the laravel controller or something else from the framework. I have tried it with die('hello'); in the first lines of /public/index.php under apache2 the line never will showed.

Für mich sieht es so aus als ob der Apache2 Server die Anfrage erst garnicht bis zum Framework weitergibt.
Testen konnte ich das ganz einfach indem Ich in den ersten Zeilen der index.php ein die('hello'); eingebaut habe. Diese Zeile wird unter dem Apache2 niemals ausgegeben. Stattdessen gibt es lediglich 2 OPTIONS HEADER Antwortern.

Kann mir da Jemand weiterhelfen?

Vielen Dank






---------------------------------------------------------------------------------------------------------




Good evening together,
i have trouble with Apache2 and Laravel by sending a request with angular 5 HttpClient.

following situation

The Laravel App run always with php artisan serve -host=0.0.0.0 on port 8000. And i can send my request for example over my local ip: 192.168.178.33

For Login i have the follow Url: http://192.168.178.33:8000/api/login
The Google Console show's me two responses OPTIONS HEADER and the second response return me the result of the laravel controller.
Code: Select all
    General
    Request URL:http://192.168.178.33:8000/api/login/
    Request Method:OPTIONS
    Status Code:200 OK
    Remote Address:192.168.178.33:8000
    Referrer Policy:no-referrer-when-downgrade

    Request Headers
    Accept:*/*
    Accept-Encoding:gzip, deflate
    Accept-Language:de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
    Access-Control-Request-Headers:content-type
    Access-Control-Request-Method:POST
    Connection:keep-alive
    Host:192.168.178.33:8000
    Origin:http://localhost:8100
    User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/64.0.3282.167 Chrome/64.0.3282.167 Safari/537.36


Second response
Code: Select all
    General
    Request URL:http://192.168.178.33:8000/api/login/
    Request Method:POST
    Status Code:200 OK
    Remote Address:192.168.178.33:8000
    Referrer Policy:no-referrer-when-downgrade

    Request Headers
    Accept:application/json, text/plain, */*
    Accept-Encoding:gzip, deflate
    Accept-Language:de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
    Connection:keep-alive
    Content-Length:43
    Content-Type:application/json
    Host:192.168.178.33:8000
    Origin:http://localhost:8100
    Referer:http://localhost:8100/?ionicplatform=android&http://localhost:8100/ionic-lab&http://localhost:8100/ionic-lab
    User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/64.0.3282.167 Chrome/64.0.3282.167 Safari/537.36

    Request Payload
    {"email":"demo@demo.com","password":"test"}


So far so good, Now when i try the same request on the same DocumentRoot under apache2 with the URL: http://192.168.178.33/api/login

I get the follow responses twice times for one request
Code: Select all
    General
    Request URL:http://192.168.178.33/api/login/
    Request Method:OPTIONS
    Status Code:301 Moved Permanently
    Remote Address:192.168.178.33:80
    Referrer Policy:no-referrer-when-downgrade

    Request Headers
    Accept:*/*
    Accept-Encoding:gzip, deflate
    Accept-Language:de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
    Access-Control-Request-Headers:content-type
    Access-Control-Request-Method:POST
    Connection:keep-alive
    Host:192.168.178.33
    Origin:http://localhost:8100
    User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/64.0.3282.167 Chrome/64.0.3282.167 Safari/537.36


My Vhost
Code: Select all
    <VirtualHost *:80>
      ServerName localhost
     Documentroot /home/alexander/PhpstormProjects/restaurant/server/public

    <Directory "/home/alexander/PhpstormProjects/restaurant/server/public">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                Require all granted
    </Directory>

    </Virtualhost>


It's the only one enabled vhost

Versions
Code: Select all
    php -v
    PHP 7.0.25-0ubuntu0.16.04.1 (cli) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.25-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

    apache2 -v
    Server version: Apache/2.4.18 (Ubuntu)
    Server built:   2017-09-18T15:09:02

    php artisan -V
    Laravel Framework 5.5.37


For me it looks like that the request never reached the laravel controller or something else from the framework. I have tried it with die('hello'); in the first lines of /public/index.php under apache2 the line never will showed.
11alex11
 
Posts: 1
Joined: 12. March 2018 21:31
XAMPP version: 3
Operating System: Ubuntu 16.04

Return to Apache

Who is online

Users browsing this forum: No registered users and 1 guest