za-ek / zaek

Za-ek PHP Framework
0 stars 0 forks source link

Порт сервера #3

Open za-ek opened 7 years ago

za-ek commented 7 years ago

При добавлении css через метод CTemplate::addCss не учитывается порт. Например, у меня nginx настроен на 8080, апач на 80, при загрузке шрифтов выходит ошибка в браузере:

Access to Font at 'http://example.com/templates/current/fonts/fontawesome-webfont.ttf?v=4.7.0' from origin 'http://example.com:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.com:8080' is therefore not allowed access.

Нужно сделать:

za-ek commented 7 years ago
public function getWebPath($value)
    {
        return 'http'.(($_SERVER['SERVER_PORT'] == 443 || isset($_SERVER['HTTPS']) || isset($_SERVER['HTTP_S'])) ? 's' : '' ).'://' . $_SERVER['SERVER_NAME']
        . ($this->_app->conf()->get('request', 'port') ? ':' . $this->_app->conf()->get('request', 'port') : '')
        .  $value;
    }