Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

CORS documentation doesn't cover CORS_ALLOWED_ORIGINS #15

Open
simbo1905 opened this issue May 7, 2018 · 2 comments
Open

CORS documentation doesn't cover CORS_ALLOWED_ORIGINS #15

simbo1905 opened this issue May 7, 2018 · 2 comments

Comments

@simbo1905
Copy link

simbo1905 commented May 7, 2018

If I look in config\cors.php it has a line:

'allowedOrigins' => env('CORS_ALLOWED_ORIGINS') ? explode(',', env('CORS_ALLOWED_ORIGINS')) : ['*'],

I was unable to get anything working until I had set an environment variable CORS_ALLOWED_ORIGINS to match the domain name where the frontend is. When I set that env var to be a string that matched the ORIGIN domain name then things worked (e.g. "frontend-sjm-staging.a3c1.starter-us-west-1.openshiftapps.com" with no protocol).

To shake this off I also bumped to laravel/framework to 5.5.* and barryvdh/laravel-cors to "^0.11.0" I haven't checked whether things works using the early versions on master in this repo.

@ctapvk
Copy link

ctapvk commented Feb 25, 2019

# set config/cors.php   to this  help  me. thanks simbo1905
    'allowedOrigins' => ['*'],

\Illuminate\Database\Eloquent\Builder::callScope

# fix php 7.2 count problem 
    protected function callScope(callable $scope, $parameters = [])
    {
        array_unshift($parameters, $this);

        $query = $this->getQuery();

        // We will keep track of how many wheres are on the query before running the
        // scope so that we can properly group the added scope constraints in the
        // query as their own isolated nested where statement and avoid issues.
        $originalWhereCount = is_array($query->wheres) ? count($query->wheres) : 0;
        $result = $scope(...array_values($parameters)) ?: $this;

        if (is_array($query->wheres) ? count($query->wheres) : 0 > $originalWhereCount) {
            $this->addNewWheresWithinGroup($query, $originalWhereCount);
        }

        return $result;
    }

or use this

if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
    // Ignores notices and reports all other kinds... and warnings
    error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
    // error_reporting(E_ALL ^ E_WARNING); // Maybe this is enough
}

@ctapvk
Copy link

ctapvk commented Jun 23, 2019 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants