我正在使用直接PostgresSQL为我的Shopify应用程序设置Shopify文档会话存储
他们说要像这样设置会话存储:
import Shopify from '@shopify/shopify-api';
Shopify.Context.initialize({
SESSION_STORAGE: new Shopify.Auth.Session.PostgreSQLSessionStorage("postgres://username:password@host/database"),
...
});
// OR
Shopify.Context.initialize({
SESSION_STORAGE: Shopify.Auth.Session.PostgreSQLSessionStorage.withCredentials(
"host.com",
"thedatabase",
"username",
"password",
),
...
});但是,当我设置它时,会遇到以下错误:
Property 'Session' does not exist on type '{ SESSION_COOKIE_NAME: string; beginAuth(request: IncomingMessage, response: ServerResponse, shop: string, redirectPath: string, isOnline?: boolean | undefined): Promise<...>; ... 4 more ...; getCurrentSessionId(request: IncomingMessage, response: ServerResponse, isOnline?: boolean | undefined): string | undefined; }'.ts(2339)
}我的服务器崩溃是因为:TypeError: Cannot read properties of undefined (reading 'PostgreSQLSessionStorage')
我尝试过直接导入PostgreSQLSessionStorage以供使用,如下所示:
import { PostgreSQLSessionStorage } from "@shopify/shopify-api/dist/auth/session/index.js";但这会遇到许多其他未定义的对象问题。
知道我哪里出问题了吗?
发布于 2022-08-01 00:28:37
你想过解决这个问题吗?移除奥斯让我更近了一点:
SESSION_STORAGE: new Shopify.Session.PostgreSQLSessionStorage(`${process.env.DATABASE_URL}?sslmode=require`),但现在我得到了
2022-08-01T00:21:05.291801+00:00 app[web.1]: node:internal/process/promises:288
2022-08-01T00:21:05.291820+00:00 app[web.1]: triggerUncaughtException(err, true /* fromPromise */);
2022-08-01T00:21:05.291821+00:00 app[web.1]: ^
2022-08-01T00:21:05.291821+00:00 app[web.1]:
2022-08-01T00:21:05.291822+00:00 app[web.1]: Error: self-signed certificate
2022-08-01T00:21:05.291823+00:00 app[web.1]: at TLSSocket.onConnectSecure (node:_tls_wrap:1534:34)
2022-08-01T00:21:05.291823+00:00 app[web.1]: at TLSSocket.emit (node:events:513:28)
2022-08-01T00:21:05.291823+00:00 app[web.1]: at TLSSocket._finishInit (node:_tls_wrap:948:8)
2022-08-01T00:21:05.291823+00:00 app[web.1]: at ssl.onhandshakedone (node:_tls_wrap:729:12) {
2022-08-01T00:21:05.291824+00:00 app[web.1]: code: 'DEPTH_ZERO_SELF_SIGNED_CERT'
2022-08-01T00:21:05.291824+00:00 app[web.1]: }发布于 2022-10-03 04:41:58
好奇的汤姆解决方案也为我工作。要结束它,要从sqlite (原始shopify CLI db)切换到heroku postgresql,您必须:
Shopify.Context.initialize中替换index.js中的代码行(请注意替换所有变量:用户名、密码、主机、数据库)。不包括"auth",而不是Shopify中显示的内容。SESSION_STORAGE: new Shopify.Session.PostgreSQLSessionStorage("postgres://username:password@host/database")https://stackoverflow.com/questions/73083363
复制相似问题