我使用的是带有子域的https://github.com/stancl/tenancy。当我从子域和我的前端(Angular)获取数据时,我得到了这个错误。
我使用https://github.com/fruitcake/laravel-cors来处理cors。
在这里,我的app/Kernel.php中包含了laravel-cors
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\Fruitcake\Cors\HandleCors::class,和我在routes\Tenant.php的路线
Route::middleware([
'web',
InitializeTenancyByDomain::class,
PreventAccessFromCentralDomains::class,
])->group(function () {
Route::get('/', function () {
dd(\App\User::all());
return response()->json('This is your multi-tenant application. The id of the current tenant is ' . tenant('id'));
});
});发布于 2020-10-25 17:38:30
实际上,使用dd()函数并不起作用。
如果我更改为
Route::middleware([
'web',
InitializeTenancyByDomain::class,
PreventAccessFromCentralDomains::class,
])->group(function () {
Route::get('/', function () {
//dd(\App\User::all());
return response()->json(App\User::all());
});
});这很管用
https://stackoverflow.com/questions/64516848
复制相似问题