我们在Kubernetes集群上托管了基于Angular的Web应用程序.此应用程序的Ingress配置为添加基本URL:
{
"kind": "Ingress",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "test-app",
"namespace": "acceptance-testing",
...
"annotations": {
"kubernetes.io/ingress.class": "nginx",
"nginx.ingress.kubernetes.io/add-base-url": "true",
"nginx.ingress.kubernetes.io/rewrite-target": "/",
"nginx.ingress.kubernetes.io/ssl-redirect": "true"
}
},
"spec": {
"rules": [
{
"http": {
"paths": [
{
"path": "/at/test-app",
"backend": {
"serviceName": "test-app",
"servicePort": 80
}
}
]
}
}
]
},
...
}
Run Code Online (Sandbox Code Playgroud)
当我们在浏览器中输入包含客户端路由部分的URL时,ingress会将整个URL添加为在我们的场景中不正确的基础.
例如,对于https:// server/at/test-app/some-page请求基本URL应为https:// server/at/test-app /但我们接收https:// server/at/test-app /一些页/
我们已经切换到Angular哈希路由位置策略,现在它正常工作但我们想知道是否有某种方法使位置路由策略与nginx入口一起工作?
预先感谢您的帮助.
最好的祝福
我有一个 Node.js,Angular 应用程序。(用 TypeScript 编写的 Node.js 服务器)。Node.js 服务器在 Amazon EC-2 实例上运行,Angular 客户端在另一台服务器上。
对于登录会话,我使用 express-session。我没有在应用程序中使用 cookie,所以我认为问题在于快速会话 cookie。 在 Firefox 上它可以正常工作,但在 Google Chrome (80.0.3987.149) 上它不起作用:Chrome 不保存会话(所以我不能离开登录页面)并警告:
与http://addressof.myserverapp.com/上的跨站点资源关联的 cookie设置为没有该
SameSite属性。它已被阻止,因为 Chrome 现在仅在设置了SameSite=None和 的情况下才提供具有跨站点请求的 cookieSecure。您可以在应用程序>存储>Cookies 下的开发人员工具中查看 cookie,并在https://www.chromestatus.com/feature/5088147346030592和https://www.chromestatus.com/feature/5633521622188032 上查看更多详细信息。
在 Node.js 服务器中,我以这种方式设置了 express-sessions:
import cookieParser from 'cookie-parser';
app.use(cookieParser(secret));
app.use(session({
secret: secret,
resave: false,
saveUninitialized: false,
cookie: {
httpOnly: false,
maxAge: null,
secure: true,
sameSite: 'none'
},
store: sessionStore // MySqlStore - express-mysql-session
}));
Run Code Online (Sandbox Code Playgroud)
我也尝试用这个代码片段解决这个问题(来自 …
对于我的MongoDB对象,我有一个架构,其中有许多嵌套数据。
但是我在GraphQL中完美实现了查询以获取数据,但是由于无法定义类型,因此无法获取嵌套数据。
fields() {
return {
name: {
type: GraphQLString,
description: 'Name of the person'
},
age: {
type: GraphQLString,
description: 'Age'
},
documents: { // what to do here
type: new GraphQLList(),
description: 'All documents for the person'
}
}
}
Run Code Online (Sandbox Code Playgroud)
原始数据是这样的。
{
"_id" : ObjectId("5ae1da5e4f00b5eee4ab84ee"),
"name" : "Indira Gandhi International Airport",
"age" : 54,
"documents" : [
{
"doc_name" : "personal card",
"doc_url" : "http://",
"status" : true
},
{
"doc_name" : "bank card",
"doc_url" : "http://",
"status" …Run Code Online (Sandbox Code Playgroud) 应用程序.js
var debug = require('debug');
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
javvar mongoose = require('mongoose');
var session = require('express-session');
var db = require('./dbconn');
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
console.log('we are connected!');
});
var index = require('./routes/index');
var users =
require('./routes/users');
var signup = require('./routes/signup');
var login = require('./routes/login');
var adreqform =
require('./routes/adreqform') var dashboard =
require('./routes/dashboard')
var app = express(); …Run Code Online (Sandbox Code Playgroud) node.js ×3
express ×2
mongoose ×2
angular ×1
graphql ×1
graphql-js ×1
javascript ×1
nginx ×1
samesite ×1