mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 08:17:24 +08:00
proper 404 for json request 404
This commit is contained in:
@ -66,6 +66,9 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
rescue_from Discourse::NotFound do
|
||||
|
||||
if request.format && request.format.json?
|
||||
render status: 404, layout: false, text: "[error: 'not found']"
|
||||
else
|
||||
f = Topic.where(deleted_at: nil, archetype: "regular")
|
||||
@latest = f.order('views desc').take(10)
|
||||
@recent = f.order('created_at desc').take(10)
|
||||
@ -74,6 +77,8 @@ class ApplicationController < ActionController::Base
|
||||
render status: 404, layout: 'no_js', template: '/exceptions/not_found'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
rescue_from Discourse::InvalidAccess do
|
||||
render file: 'public/403', formats: [:html], layout: false, status: 403
|
||||
end
|
||||
|
Reference in New Issue
Block a user