我们有一个土耳其网站,一些旧链接被一些搜索引擎抓取.链接似乎格式不正确或无法处理,从而导致ActionController::BadRequest
错误.在本地计算机上development env
导致返回Rails错误页面ActionController::BadRequest
.
但是在服务器上我们得到了一个500 server error
.这个问题在这里的其他几个页面上讨论过.但是这些解决方案都没有帮助.
在这两种情况下,我们page not found
都想重定向到-page.
我已经尝试过rescue_from ActionController::BadRequest
,并rescue_from ActionController::RoutingError
在ApplicationController
因上述物品的,他们指出BadRequest
变成RoutingError
.
但他们都没有奏效.
我希望有人遇到同样的问题并且已经解决了.提前感谢您的回答.
编辑:
一个示例问题 - 网址是http://localhost:3000/Di%c5%ef%bf%bd-f%c4%b1r%c3%a7as%c4%b1
.
终端输出:
ActionController::BadRequest (ActionController::BadRequest):
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:37:in `block in call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:33:in `each'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:33:in `call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
newrelic_rpm (3.6.4.122) lib/new_relic/rack/error_collector.rb:12:in `call' …
Run Code Online (Sandbox Code Playgroud) 我知道这个问题已经以多种不同的形式被提出。但我已经阅读了我能找到的关于此事的所有帖子和文章,但无法根据我们面临的先决条件解决我的问题。因此,我想首先描述我们的问题并给出我们的动机,然后描述我们已经尝试过或正在使用的不同方法,尽管它们并不令人满意。
我们的设置可以说是有些复杂。我们的 Angular 应用程序部署在多个 Kubernetes 集群上,并通过不同的路径提供服务。
集群本身位于代理后面,并且 Kubernetes 本身添加了一个名为 Ingress 的代理。因此,我们的常见设置可能如下所示:
当地的
http://本地主机:4200/
本地集群
https://kubernetes.local/angular-app
发展
https://ourcompany.com/proxy-dev/kubernetes/angular-app
分期
https://ourcompany.com/proxy-staging/kubernetes/angular-app
顾客
https://kubernetes.customer.com/angular-app
应用程序始终以不同的基本路径提供服务。由于这是 Kubernetes,我们的应用程序是使用 Docker 容器部署的。
通常,人们会使用ng build
转译 Angular 应用程序,然后使用如下所示的 Dockerfile:
FROM nginx:1.17.10-alpine
EXPOSE 80
COPY conf/nginx.conf /etc/nginx/conf.d/default.conf
RUN rm -rf /usr/share/nginx/html/*
COPY dist/ /usr/share/nginx/html/
Run Code Online (Sandbox Code Playgroud)
要告诉 CLI 如何设置 base-href 以及从何处提供资源,可以使用Angular CLI 的--base-href
和选项。--deploy-url
不幸的是,这意味着我们需要为每个要部署应用程序的环境构建一个 Docker 容器。
此外,我们必须注意在这个预构建过程中设置其他环境变量,例如在environments[.prod].ts
每个部署环境中。
我们当前的解决方案包括在部署期间构建应用程序。这是通过使用另一个 Docker 容器作为所谓的initContainer来实现的,该容器在 nginx 容器启动之前运行。
该 Dockerfile 如下所示:
FROM node:13.10.1-alpine
# set working …
Run Code Online (Sandbox Code Playgroud) 我有以下
#include <iostream>
#include <memory>
template<typename _type>
class handle
{
using ptr = std::shared_ptr<_type>;
using pptr = std::shared_ptr<ptr>;
public:
handle(handle<_type> const & other) :
mData(make_pptr(*(other.mData)))
{}
handle(_type && data) :
mData(make_pptr(std::move(data)))
{}
private:
pptr mData;
template<typename ..._args>
constexpr auto make_ptr(_args && ...args)
{
return std::make_shared<_type>(std::forward<_args>(args)...);
}
constexpr auto make_pptr(ptr const & pointer)
{
return std::make_shared<ptr>(pointer);
}
template<typename ..._args>
constexpr auto make_pptr(_args && ...args)
{
return std::make_shared<ptr>(make_ptr(std::forward<_args>(args)...));
}
};
int main()
{
handle<int> h = 5;
handle<int> h2(h);
}
Run Code Online (Sandbox Code Playgroud)
用g++-4.9 …
angular ×1
base-path ×1
c++ ×1
c++14 ×1
docker ×1
kubernetes ×1
ruby ×1
server-error ×1
shared-ptr ×1