2

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: https://www.traapp.tk/api/data/20190809 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.

.htacces

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

    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]
</IfModule>

api.php

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


Route::get('data/{date}', 'MainController@index');

Route::post('route', 'MainController@getAllRoutesOfACertainDay');

MainController

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

2
  • Can you show your MainController@index? You're not throwing a 404 there, are you? Commented Aug 9, 2019 at 15:21
  • @aynber I updated that for you Commented Aug 9, 2019 at 15:26

2 Answers 2

1

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>
    ServerName.....
Sign up to request clarification or add additional context in comments.

5 Comments

Looks like that is out my hand in my Shared host subscription, let you know if it works when I contacted support
Why won't bold do? What about italics?
Looking at my browser I'd say bold does stand out more than the grey background of code - which is almost unnoticeable when looking at an angle.
Regarding your linked post: it says the only appropriate reason for abusing code-formatting is if you need the monospaced font, not the background coloring and generally discourages your use of backticks. I won't discuss this further, just wanted to mention that your (selfmade?) UX-rules goes against all established rules of typesetting I ever heard of. Just wondering when the good old blinking text will be back since it does a so much better job at focussing attention....
0

First try to enter to GET routes, if you have 403 or 404, the problem is the nginx configuration, look the log, and if the problem is the doesn't find index.html in public_html is the root configuration of your nginx or apache2

Apache 2 has te config in the /etc/apache2/sites-enabled/ and your-domain.conf when you activate ssl in your site the problem can be, that the site generates another conf file, like your-domain.ssl.conf and this file looks like

ServerName domain.com
ServerAlias www.domain.com
ServerAdmin [email protected]
DocumentRoot /home/admin/web/domain.com/public_html/public <----- here is the change
ScriptAlias /cgi-bin/ /home/admin/web/pdomain.com/cgi-bin/
Alias /vstats/ /home/admin/web/domain.com/stats/
Alias /error/ /home/admin/web/domain.com/document_errors/
#SuexecUserGroup admin admin
CustomLog /var/log/apache2/domains/domain.com.bytes bytes
CustomLog /var/log/apache2/domains/domain.com.log combined
ErrorLog /var/log/apache2/domains/domain.com.error.log
<Directory /home/admin/web/domain.com/public_html>
    AllowOverride All
    SSLRequireSSL
    Options +Includes -Indexes +ExecCGI
    php_admin_value open_basedir /home/admin/web/domain.com/public_html:/home/admin/tmp
    php_admin_value upload_tmp_dir /home/admin/tmp
    php_admin_value session.save_path /home/admin/tmp
</Directory>
<Directory /home/admin/web/domain.com/stats>
    AllowOverride All
</Directory>
SSLEngine on
SSLVerifyClient none
SSLCertificateFile /home/admin/conf/web/ssl.domain.com.crt
SSLCertificateKeyFile /home/admin/conf/web/ssl.domain.com.key
SSLCertificateChainFile /home/admin/conf/web/ssl.domain.com.ca

<IfModule mod_ruid2.c>
    RMode config
    RUidGid admin admin
    RGroups www-data
</IfModule>
<IfModule itk.c>
    AssignUserID admin admin
</IfModule>

IncludeOptional /home/admin/conf/web/sapache2.domain.com.conf*

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.