简体   繁体   English

Laravel 5.4 Route :: post()NotFoundException

[英]Laravel 5.4 Route::post() NotFoundException

Hi I have a problem with Laravel 5.4 routes, Route::get() are working but Route::post() give me NotFoundException error back. 嗨,我有一个Laravel 5.4路由问题,Route :: get()正常工作,但Route :: post()给我NotFoundException错误。

Take a look at login route in api.php this one is for sure not working but was working before I started using Homestead and vagrant. 看看api.php中的登录路由,这肯定是行不通的,但是在我开始使用Homestead和vagrant之前,它已经在运行。

Any ideas ? 有任何想法吗 ? Here are my interresting configurations about API and routes (Hosted files on github) : 这是我有关API和路由的有趣配置(github上的托管文件):

1) RouteServiceProvider.php 1) RouteServiceProvider.php

2) api.php 2) api.php

3) Kernel.php 3) Kernel.php

Can't understand why ! 不明白为什么! If needed I can upload full project but I can't stand why it doesn't work since start of the week. 如果需要,我可以上传完整的项目,但是我无法忍受为什么自本周开始以来它不起作用。

Please be kind with me this is my first project with Laravel. 请对我好一点,这是我与Laravel合作的第一个项目。

Kind regards 亲切的问候

Edit : Just added php artisan route:list --path:foobar result : 编辑:刚刚添加了php artisan route:list --path:foobar结果:

route-list-ouptut 路由列表输出

Your code seems fine, except I would remove these lines from api.php : 您的代码看起来不错,除了我将从api.php删除这些行:

header('Access-Control-Allow-Origin:  *');
header('Access-Control-Allow-Methods:  POST, GET, OPTIONS, PUT, DELETE');
header('Access-Control-Allow-Headers:  Content-Type, Authorization');

As I understand these are request headers. 据我了解,这些是请求标头。 So you should add the in your Postman request headers (or another Rest client). 因此,您应该在邮递员请求标头(或其他Rest客户)中添加。 And not in any where in your code. 而不是在代码中的任何地方。

If you want to add headers to response, rather then request here are Laravel Create Response Docs 如果您想添加标题以响应,那么请在此处请求Laravel创建响应文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM