Laravel 与Vagrant进行POST请求时连接被拒绝

Laravel 与Vagrant进行POST请求时连接被拒绝,laravel,http,post,vagrant,Laravel,Http,Post,Vagrant,我有一个API,可以很好地与GET协议配合使用 我正在尝试使用POST,但无法访问它 使用Vagrant SSH或测试站点,它会被拒绝: vagrant@smyprojectt:~$ curl -X POST -v http://127.0.0.1:8080/api/xml/ * Trying 127.0.0.1... * TCP_NODELAY set * connect to 127.0.0.1 port 8080 failed: Connection refused * Failed

我有一个API,可以很好地与GET协议配合使用

我正在尝试使用POST,但无法访问它

使用Vagrant SSH或测试站点,它会被拒绝:

vagrant@smyprojectt:~$ curl -X POST -v http://127.0.0.1:8080/api/xml/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* connect to 127.0.0.1 port 8080 failed: Connection refused
* Failed to connect to 127.0.0.1 port 8080: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused
在外面直接做这件事给了我这个答案:

me@myuser:~$ curl -X POST -v http://127.0.0.1:8080/api/xml/
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> POST /api/xml/ HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Date: Wed, 09 Jan 2019 09:50:46 GMT
< Server: Apache/2.4.25 (Debian)
< Location: http://127.0.0.1:8080/api/xml
< Content-Length: 322
< Content-Type: text/html; charset=iso-8859-1
< 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://127.0.0.1:8080/api/xml">here</a>.</p>
<hr>
<address>Apache/2.4.25 (Debian) Server at 127.0.0.1 Port 8080</address>
</body></html>
* Connection #0 to host 127.0.0.1 left intact
me@myuser:~$curl-X POST-vhttp://127.0.0.1:8080/api/xml/
*正在尝试127.0.0.1。。。
*连接到127.0.0.1(127.0.0.1)端口8080(#0)
>POST/api/xml/HTTP/1.1
>主持人:127.0.0.1:8080
>用户代理:curl/7.47.0
>接受:*/*
> 


位于127.0.0.1端口8080的Apache/2.4.25(Debian)服务器 *0到主机127.0.0.1的连接保持不变
应用程序的其余部分工作正常,包括AJAX或使用POST的表单,但这一请求尤其遭到拒绝


有什么帮助吗?

正在使用CSRF令牌验证每个POST/PATCH/PUT/DELETE请求。因此,您可以在请求中传递令牌,或者在
Http/Kernel.php
文件中注释掉
\App\Http\Middleware\VerifyCsrfToken::class,
中的
$middlewareGroups
数组中的
,以便进行测试