- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法获得针对我的应用程序的 ajax 请求的描述性错误消息。我不认为这是如何设置的。我已经尝试完全删除 Controller 方法,但在它接触 Controller 之前仍然失败。
我的路线:
+--------+----------+------------------------+-------+--------------------------------------------------------------+---------------------------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+------------------------+-------+--------------------------------------------------------------+---------------------------------+
| | POST | subscribe | | App\Http\Controllers\SubscriptionController@create | web,auth |
+--------+----------+------------------------+-------+--------------------------------------------------------------+---------------------------------+
Route::group([
'middleware' => 'auth',
], function () {
Route::post('subscribe', 'SubscriptionController@create');
Route::post('unsubscribe', 'SubscriptionController@delete');
});
this.$http.post('/subscribe', {
my-data: 'values'
}).then(response => {
// success
}, response => {
console.error('Failed to subscribe');
});
{
"message": "",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\HttpException",
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
"line": 203,
"trace": [
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
"line": 175,
"function": "prepareException",
"class": "Illuminate\\Foundation\\Exceptions\\Handler",
"type": "->"
},
{
"file": "/var/www/html/app/Exceptions/Handler.php",
"line": 53,
"function": "render",
"class": "Illuminate\\Foundation\\Exceptions\\Handler",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 83,
"function": "render",
"class": "App\\Exceptions\\Handler",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 55,
"function": "handleException",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php",
"line": 49,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\View\\Middleware\\ShareErrorsFromSession",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php",
"line": 63,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Session\\Middleware\\StartSession",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php",
"line": 37,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php",
"line": 59,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\EncryptCookies",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 102,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 647,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 622,
"function": "runRouteWithinStack",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 588,
"function": "runRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 577,
"function": "dispatchToRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 176,
"function": "dispatch",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 30,
"function": "Illuminate\\Foundation\\Http\\{closure}",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/var/www/html/vendor/fideloper/proxy/src/TrustProxies.php",
"line": 56,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Fideloper\\Proxy\\TrustProxies",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 30,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 30,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
"line": 27,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php",
"line": 46,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 102,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 151,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 116,
"function": "sendRequestThroughRouter",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/var/www/html/public/index.php",
"line": 53,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
}
]
}
最佳答案
在 web 部分( web.php
路由文件)有一个 CSRF
使用 VerifyCsrfToken
进行验证中间件作为 doc说:
The VerifyCsrfToken middleware, which is included in the web middleware group, will automatically verify that the token in the request input matches the token stored in the session.
api.php
路由文件)中,女巫专用于“无状态”API 调用,没有
CSRF
验证,但您应该通过
JWT
使用 API 身份验证或
Laravel Passport
例如。
X-CSRF-TOKEN
使用生成的值
csrf_token
的 ajax 调用 header 您可以从元标记中获取它,例如:
<meta name="_token" content="{{ csrf_token() }}"/>
$.ajaxSetup
在ajax调用之前:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
}
});
$.ajax({
url: "/subscribe",
// ....
})
关于Laravel HttpException - 没有错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46449768/
我无法获得针对我的应用程序的 ajax 请求的描述性错误消息。我不认为这是如何设置的。我已经尝试完全删除 Controller 方法,但在它接触 Controller 之前仍然失败。 我的路线: +-
我在测试项目中遇到了一些问题。C#、ASP .NET MVC 5、>NET Framework 4.5.1 出于某种原因,我的异常过滤器无法捕获 Controller 抛出的 HttpExceptio
我是 aspx 网络表单的新手。 我想在我的 Web 应用程序中捕获特定异常 - Viewstate MAC 验证失败。 我试过这个(在 Global.asax.cs 中): protected vo
我正在使用 Retrofit 向 API 发出一些请求,当我收到响应时,如果请求成功,通常会以这种格式从 API 收到响应 成功响应 { "success": 1, "error":
该文档建议引发带有客户端错误的 HTTPException,这很好。 但是如何在文档中遵循 HTTPException 的模型显示这些特定错误?意思是带有“详细信息”键的字典。 以下不起作用,因为 H
我正在尝试处理 http 错误,所以我创建了自定义 http 异常类 class HttpException implements Exception { final String message
我在2个不同的服务器上的项目中工作。该代码是从bitbucket克隆的,因此完全相同,但是在其中一个中,我在每个HTTP请求中均收到此错误: Couldn't connect to host, Ela
我正在尝试测试这个方法: private ServiceApiMetadata getConfig(final HttpServletRequest request, final String pat
我正在尝试使用 Windows 上的 AllegroGraph 客户端(版本 4.1.1)将 *.nt 文件导入 AllegroGraph。我使用 AllegroGraph WebView 应用程序来
我正在使用 ASP.NET MVC 3 开发 uploader 。我正在使用 AJAX 上传控件 (http://valums.com/ajax-upload/)。当我尝试通过 IE 上传大文件时,一
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Troubleshooting BadImageFormatException 我正在尝试编译我的解决方案,
我的 output.aspx 页面有时会出现以下错误: Exception Details: System.Web.HttpException: Request timed out. Source E
出于测试目的,我有这个方法: public ActionResult Index() { System.Diagnostics.Debug.Write("Index"); return
我在 Laravel 中进行单元测试的一个测试函数不断出错。我试图断言在不满足某些条件的情况下请求特定页面会触发 403 FORBIDDEN 错误。 我的测试用例函数是这样的: public func
httplib.HTTPException 是否有错误代码?如果是这样,我如何从异常实例中获取它们?感谢您的帮助。 最佳答案 httplib 模块不使用异常来传达 HTTP 响应,只是真正的错误(无效
我已经编写了一个自定义的 http 处理程序。我通过编写一个实现 IHttphandler 的类来完成此操作。 在那个类中我有这样的代码, context.Response.Clear(); cont
我在 Azure WebApp 中有一个 REST API。当 POST 发送到我的端点时,我会进行一些检查,如果需要,我会抛出 HttpException: throw new HttpExcept
当我对 ClaimsIdentity 中的某些声明执行“foreach”循环时遇到问题。当我单步执行它时 - 在它应该完成枚举时,我看到它返回到“in”,然后在我收到有关与 SQL Server 连接
function ValidateProductID(sender, args) { var productID = document.getElementById('').value;
我有一个 Silverlight/ASP 托管应用程序。当我开始时,我得到错误: HttpException occurred File does not exist. 这是昨天才开始发生的,我不知道
我是一名优秀的程序员,十分优秀!