我正在使用 Clerk 为我的应用程序实施身份验证。这是一个仅在内部使用的应用程序,因此我只希望我授予访问权限的人能够登录。我真的不希望任何人都能够自己注册。我喜欢 Clerk,因为它可以轻松地向应用程序添加身份验证,但我没有找到禁用注册功能的方法。有人试过这个吗?
我一直在开发 JS Mastery 的线程视频并遇到此错误:
- error node_modules\@clerk\shared\dist\esm\hooks\createContextAndHook.js (4:0) @ assertContextExists
- error Error: ClerkInstanceContext not found
null
Run Code Online (Sandbox Code Playgroud)
谁能帮我?
我尝试了很多方法,但似乎没有任何方法可以解决我的问题
使用 Clerk Auth,我可以使用 Next.js 13 中间件实现有效的登录/注册流程。
当用户注册时,我想向数据库Users表添加一行。
中间件的问题是它在每个请求上运行,我不想调用我的数据库来检查用户是否存在,以便我可以创建记录。
Clerk 是否会返回任何可用于区分注册与正常请求的数据?
在我托管在 vercel 上的生产站点上,经过职员身份验证后,它会将我重定向到本地主机。这种情况仅发生在我用于开发的笔记本电脑上。
如果我连接到另一台设备上的生产站点,它会在身份验证后正确地将我重定向回 vercel 上托管的生产站点。
我正在关注 t3 堆栈的教程:https://www.youtube.com/watch ?v=YkOSUVzOAA4
我是这个堆栈的新手,并且使用 nextJS + vercel + clerk,所以我不知道从哪里开始。我将上传任何需要的代码。谢谢。
我正在尝试将我的 Clerk 数据同步到 Next js 13 项目中的数据库。我的 webhooks 通过 Ngrok 公开暴露。这是我的代码:
import { IncomingHttpHeaders } from "http";
import { headers } from "next/headers";
import { NextResponse } from "next/server";
import { Webhook, WebhookRequiredHeaders } from "svix";
const webhookSecret = process.env.WEBHOOK_SECRET || "";
async function handler(request: Request) {
console.log(await request.json())
const payload = await request.json();
const headersList = headers();
const heads = {
"svix-id": headersList.get("svix-id"),
"svix-timestamp": headersList.get("svix-timestamp"),
"svix-signature": headersList.get("svix-signature"),
};
const wh = new Webhook(webhookSecret);
let evt: Event | null = …Run Code Online (Sandbox Code Playgroud) 我尝试使用职员进行身份验证。在本地运行良好。但是,当我通过 vercel 在生产中部署时它不起作用。它表明This Edge Function has crashed.。我不知道这里发生了什么。有人有想法吗?我正在使用 nextjs 应用程序目录。
"react": "18.2.0",
"react-dom": "18.2.0",
"next": "13.4.12",
"next-intl": "^2.19.0",
Run Code Online (Sandbox Code Playgroud)
中间件.ts
"react": "18.2.0",
"react-dom": "18.2.0",
"next": "13.4.12",
"next-intl": "^2.19.0",
Run Code Online (Sandbox Code Playgroud)
next.config.js
import { authMiddleware } from "@clerk/nextjs";
import createMiddleware from "next-intl/middleware";
const intlMiddleware = createMiddleware({
locales: ["en", "zh"],
defaultLocale: "en",
});
export default authMiddleware({
beforeAuth: (req) => {
return intlMiddleware(req);
},
publicRoutes: ["/"],
});
// export default authMiddleware();
export const config = {
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};
Run Code Online (Sandbox Code Playgroud) 再会,
我一直在尝试使用应用程序路由器在下一个最新版本上设置 Clerk。
我已经阅读了写得很好的文档,而且设置起来似乎非常简单,所以我在我一直在从事的一个新项目上尝试了一下。
我已按照 CLerk 提供的入门说明进行操作,但没有成功:https://clerk.com/docs/nextjs/get-started-with-nextjs
我面临的问题是,一旦登录或注册获得授权,我就会被重定向到我按计划在 env.local 中设置的路由,但我开始无限循环 GET http://localhost:3000/ 401 (未经授权)错误。摆脱该循环的唯一方法是停止 Next 服务器或删除 Clerk 存储的本地存储文件
我虽然在初始设置中犯了错误,但每次我查看说明时,我都会一遍又一遍地面临同样的问题。
我还尝试在 Github clerkinc/clerk-next-app-router-starter 上运行 Clerk 提供的示例,但出现了相同的错误。我执行的唯一手动设置是在 .env.local 文件中添加 API 密钥和 Secret
-遵循 CLerk 提供的入门说明 -尝试多个浏览器 (Firefox/Chrome) -运行 clerkinc/clerk-next-app-router-starter 存储库示例 -创建另一个 Clerk 应用程序 9 个用户池)
如上所述,一切似乎都是根据官方文档设置的
我期待着利用一个身份验证产品来完成大部分繁重的工作。任何人都面临同样的问题,或者会推荐一条研究路径,因为我在这里失去了主意?
谢谢
尚未能够深入了解此问题的根本原因,但我正在尝试使用 NextJS 12.2.2 实现文员身份验证,并且我在开发环境中一切正常。然而,当我进入生产环境时,由于以下错误,我的网站在加载时立即崩溃:
ReferenceError: __import_unsupported is not defined
at (vc/edge/function:14:2050)
at (vc/edge/function:14:656)
at (vc/edge/function:14:3107)
at (vc/edge/function:14:656)
at (vc/edge/function:67:13871)
at (vc/edge/function:14:656)
at (vc/edge/function:67:15731)
at (vc/edge/function:14:656)
at (vc/edge/function:67:27265)
at (vc/edge/function:14:656)
ReferenceError: __import_unsupported is not defined
at (external root " __import_unsupported('buffer')":1:0)
at (webpack/bootstrap:21:0)
at (node_modules/rfc4648/lib/index.mjs:11:15)
at (webpack/bootstrap:21:0)
at (node_modules/@clerk/nextjs/dist/server/clerk.js:5:18)
at (webpack/bootstrap:21:0)
at (node_modules/@clerk/nextjs/dist/server/index.js:4:21)
at (webpack/bootstrap:21:0)
at (node_modules/@clerk/nextjs/server.js:1:0)
at (webpack/bootstrap:21:0)
Run Code Online (Sandbox Code Playgroud)
我的 Clerk middleware.js 文件:
import { withClerkMiddleware } from "@clerk/nextjs/server";
import { NextResponse } from "next/server";
export default withClerkMiddleware((req) => {
return NextResponse.next(); …Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,在该项目中创建了一个登录对话框,但我收到一个无法解决的错误,我在上面的照片中给出了什么,并要求您以某种方式回答它。
- error node_modules/@clerk/shared/dist/esm/hooks/createContextAndHook.js (4:0) @ assertContextExists
- error Error: ClerkInstanceContext not found
null
Run Code Online (Sandbox Code Playgroud)
错误:
Unhandled Runtime Error
Error: ClerkInstanceContext not found
Call Stack
assertContextExists
node_modules/@clerk/shared/dist/esm/hooks/createContextAndHook.js (4:0)
useCtx
node_modules/@clerk/shared/dist/esm/hooks/createContextAndHook.js (13:0)
HOC
node_modules/@clerk/clerk-react/dist/esm/components/withClerk.js (10:43)
renderWithHooks
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (10697:0)
updateFunctionComponent
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (15180:0)
mountLazyComponent
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (15620:0)
beginWork$1
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (17316:0)
beginWork
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (25689:0)
performUnitOfWork
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (24540:0)
workLoopSync
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (24256:0)
renderRootSync
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (24211:0)
recoverFromConcurrentError
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (23446:0)
performConcurrentWorkOnRoot
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (23352:0)
workLoop
node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js (261:0)
flushWork
node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js (230:0)
MessagePort.performWorkUntilDeadline
node_modules/next/dist/compiled/scheduler/cjs/scheduler.development.js (537:0)
Run Code Online (Sandbox Code Playgroud)
我需要解决该主页上的问题并按照安排赋予其核心
clerk ×9
next.js ×8
reactjs ×3
vercel ×2
app-router ×1
middleware ×1
next.js13 ×1
ngrok ×1
oauth ×1
typescript ×1
webhooks ×1