仅允许Laravel的一个主机的要求
我有一个名为neofrontend.com的正面,我想限制我的后端仅接受neofrontend.com的请求。
public function handle(Request $request, Closure $next)
{
if(
$request->getHost() !== 'neofrontend.com'
&&
$request->getHost() !== '127.0.0.1'
)
{
return response("El host {$request->getHost()} no es compatible ", 400);
}
return $next($request);
}
我尝试了这个中间件,但它总是将我的后端主机送回我,我该怎么办?
编辑: 我尝试将其添加到cors.php中,
'allowed_origins' => ['*.neofrontend.com'],
但它不起作用
I have a fronted named neofrontend.com and I want restrict my backend to only accept request from neofrontend.com.
public function handle(Request $request, Closure $next)
{
if(
$request->getHost() !== 'neofrontend.com'
&&
$request->getHost() !== '127.0.0.1'
)
{
return response("El host {$request->getHost()} no es compatible ", 400);
}
return $next($request);
}
I tried this middleware but it always return me my backend host, What can I do?
EDIT:
I tried adding this to cors.php
'allowed_origins' => ['*.neofrontend.com'],
But it doesn't work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
$ _ server ['http_host']
:Use
$_SERVER['HTTP_HOST']
: