【发布时间】:2023-03-08 11:50:02
【问题描述】:
我想在我的 laravel 中允许 CORS 的两个域能够在本地和服务器上使用它,因此我不想将我的应用程序暴露给任何域。这就是我现在所拥有的
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', 'http://localhost:4200')
// ->header('Access-Control-Allow-Origin', 'http://api.example.com')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE')
->header('Access-Control-Allow-Headers', 'Content-Type');
}
我既不能像我评论的那样做,也不能像数组那样做
【问题讨论】:
标签: php laravel cors dingo-api