dingo / api

A RESTful API package for the Laravel and Lumen frameworks.
BSD 3-Clause "New" or "Revised" License
9.32k stars 1.25k forks source link

nginx proxy apache, no https #1741

Closed ztj1993 closed 3 years ago

ztj1993 commented 4 years ago
Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 7.x
Package version 3.0.0
PHP version 7.x

Actual Behaviour

ngxin proxy apache, Domain name: https://test.com , model () - > paginate (10); the generated domain name is wrong, there is no HTTPS.

I found some solutions, but most of them couldn't solve the problem.

{
    "current_page": 1,
    "data": [],
    "first_page_url": "http://test.com/?page=1"
}

Expected Behaviour

Expected generation:

{
    "current_page": 1,
    "data": [],
    "first_page_url": "https://test.com/?page=1"
}

Steps to Reproduce

nginx proxy apache nginx setting https


The above is from software translation.

iBet7o commented 3 years ago

you could try using

\URL::forceScheme('https');
ztj1993 commented 3 years ago

@iBet7o https://laravel.com/docs/7.x/requests#configuring-trusted-proxies

thank you! This should be the most effective method. I have already practiced it.