workos 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -41,11 +41,15 @@ Next.js version?
|
|
|
41
41
|
|
|
|
42
42
|
+-- 16+ --> Create proxy.ts at project root
|
|
43
43
|
|
|
|
44
|
-
+--
|
|
44
|
+
+-- 15 --> Create middleware.ts (cookies() is async - handlers must await)
|
|
45
|
+
|
|
|
46
|
+
+-- 13-14 --> Create middleware.ts (cookies() is sync)
|
|
45
47
|
```
|
|
46
48
|
|
|
47
49
|
**Critical:** File MUST be at project root (or `src/` if using src directory). Never in `app/`.
|
|
48
50
|
|
|
51
|
+
**Next.js 15+ async note:** All route handlers and middleware accessing cookies must be async and properly await cookie operations. This is a breaking change from Next.js 14.
|
|
52
|
+
|
|
49
53
|
Middleware/proxy code: See README for `authkitMiddleware()` export pattern.
|
|
50
54
|
|
|
51
55
|
## Step 5: Create Callback Route
|
|
@@ -60,6 +64,17 @@ URI path --> Route location
|
|
|
60
64
|
|
|
61
65
|
Use `handleAuth()` from SDK. Do not write custom OAuth logic.
|
|
62
66
|
|
|
67
|
+
**CRITICAL for Next.js 15+:** The route handler MUST be async and properly await handleAuth():
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
// CORRECT - Next.js 15+ requires async route handlers
|
|
71
|
+
export const GET = handleAuth();
|
|
72
|
+
|
|
73
|
+
// If handleAuth returns a function, ensure it's awaited in request context
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Check README for exact usage. If build fails with "cookies outside request scope", the handler is likely missing async/await.
|
|
77
|
+
|
|
63
78
|
## Step 6: Provider Setup
|
|
64
79
|
|
|
65
80
|
Wrap app in `AuthKitProvider` in `app/layout.tsx`. See README for import path.
|
|
@@ -90,6 +105,17 @@ All checks must pass before marking complete.
|
|
|
90
105
|
|
|
91
106
|
## Error Recovery
|
|
92
107
|
|
|
108
|
+
### "cookies was called outside a request scope" (Next.js 15+)
|
|
109
|
+
**Most common cause:** Route handler not properly async or missing await.
|
|
110
|
+
|
|
111
|
+
Fix for callback route:
|
|
112
|
+
1. Check that `handleAuth()` is exported directly: `export const GET = handleAuth();`
|
|
113
|
+
2. If using custom wrapper, ensure it's `async` and awaits any cookie operations
|
|
114
|
+
3. Verify authkit-nextjs SDK version supports Next.js 15+ (check README for compatibility)
|
|
115
|
+
4. **Never** call `cookies()` at module level - only inside request handlers
|
|
116
|
+
|
|
117
|
+
This error causes OAuth codes to expire ("invalid_grant"), so fix the handler first.
|
|
118
|
+
|
|
93
119
|
### "middleware.ts not found"
|
|
94
120
|
- Check: File at project root or `src/`, not inside `app/`
|
|
95
121
|
- Check: Filename matches Next.js version (proxy.ts for 16+, middleware.ts for 13-15)
|