API Routes Using Https On Laravel Gives 404

- 1 answer

I created an Laravel API.

First, it was using HTTP, I needed to change it to use https.

So I created an account on Cloudflare and since then when I go to my API endpoints:

GET: it gives a 404:

Not Found

The requested URL /api/data/20190809 was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I also have a POST request and that returns a 404 to.


<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]


Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();

Route::get('data/{date}', '[email protected]');

Route::post('route', '[email protected]');


public function index ($date) {
        $responseServer = json_decode($this->makeRequest(str_replace('DATE', $date, env('BASE_URL') . env('SCHEDULES'))),true);
        return $this->respond($responseServer);

I tried solutions like these:

Force Laravel to use HTTPS version

How to implement HTTPS in laravel 5.4



That's a 404 from your Web server not from your laravel. I guess you forgot to change the declared port in your Vhost configuration from 80 to 443.

Cloudflare example:

<VirtualHost *:443>