Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no $baseURL set will be notice "The baseURL value must be set" #1476

Closed
yangyunzhi opened this issue Nov 13, 2018 · 5 comments
Closed

no $baseURL set will be notice "The baseURL value must be set" #1476

yangyunzhi opened this issue Nov 13, 2018 · 5 comments

Comments

@yangyunzhi
Copy link

yangyunzhi commented Nov 13, 2018

my code

#File:App.php
public $baseURL = '';

it's will be notice

You have an empty or invalid base URL. The baseURL value must be set in Config\App.php, or through the .env file.

So, I modified the page IncomingRequest.php ,Let it automatically get $baseURL.

#File:IncomingRequest.php
#Function detectURI()
#Add Codes in 576line

// baseURL, so let's help them out.
if(empty($baseURL)){
$httpType = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ||
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
$baseURL = $httpType . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']);
}

It's Ok , hahaha

@yangyunzhi
Copy link
Author

I wonder if this is feasible, please enlighten me.

@jim-parry
Copy link
Contributor

We do not recommend changing any of the system files (IncomingRequest) in your webapps.
If you think this is something worthy, propose it as a feature (on the forum) or submit a PR for it (here).

The comment for $baseURL inside Config.App already says that CodeIgniter will try to guess this.

You say you get an error 500 ... can you elaborate? Do your error logs shed any loght on things? Is this for every page? What is your configuration?

Turn off the bolding before doing anything - it hurts the eyes and does serve a useful purpose! :-/

@yangyunzhi
Copy link
Author

The descript is not right, I'm so sorry

@lonnieezell
Copy link
Member

A lot of people will modify the base script to do that automatically, I'm sure. However, we've chosen to force the user to set that for security reasons. That way all URLs that are built with our URL helpers will only use a known value. Eliminates any possibilities of client interference with the URL.

@yangyunzhi
Copy link
Author

I see. Thank you.

However, for new users, it is not very friendly to prompt for "You have an empty or invalid base URL. The baseURL value must be set in Config\App.php, or through the .env file." for the first time.

@yangyunzhi yangyunzhi changed the title no $baseURL set will be error 500 no $baseURL set will be notice "The baseURL value must be set" Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants