@@ -31,7 +31,7 @@ import Slack from "next-auth-core/providers/slack"
31
31
import Spotify from "next-auth-core/providers/spotify"
32
32
import Trakt from "next-auth-core/providers/trakt"
33
33
import Twitch from "next-auth-core/providers/twitch"
34
- import Twitter , { TwitterLegacy } from "next-auth-core/providers/twitter"
34
+ import Twitter from "next-auth-core/providers/twitter"
35
35
import Vk from "next-auth-core/providers/vk"
36
36
import Wikimedia from "next-auth-core/providers/wikimedia"
37
37
import WorkOS from "next-auth-core/providers/workos"
@@ -113,7 +113,7 @@ export const authOptions: AuthOptions = {
113
113
Spotify ( { clientId : process . env . SPOTIFY_ID , clientSecret : process . env . SPOTIFY_SECRET } ) ,
114
114
Trakt ( { clientId : process . env . TRAKT_ID , clientSecret : process . env . TRAKT_SECRET } ) ,
115
115
Twitch ( { clientId : process . env . TWITCH_ID , clientSecret : process . env . TWITCH_SECRET } ) ,
116
- Twitter ( { version : "2.0" , clientId : process . env . TWITTER_ID , clientSecret : process . env . TWITTER_SECRET } ) ,
116
+ Twitter ( { clientId : process . env . TWITTER_ID , clientSecret : process . env . TWITTER_SECRET } ) ,
117
117
// TwitterLegacy({ clientId: process.env.TWITTER_LEGACY_ID, clientSecret: process.env.TWITTER_LEGACY_SECRET }),
118
118
Vk ( { clientId : process . env . VK_ID , clientSecret : process . env . VK_SECRET } ) ,
119
119
Wikimedia ( { clientId : process . env . WIKIMEDIA_ID , clientSecret : process . env . WIKIMEDIA_SECRET } ) ,
@@ -132,25 +132,24 @@ if (authOptions.adapter) {
132
132
133
133
// TODO: move to next-auth/edge
134
134
function Auth ( ...args : any [ ] ) {
135
- if ( args . length === 1 )
136
- return async ( req : Request ) => {
137
- args [ 0 ] . secret ??= process . env . NEXTAUTH_SECRET
138
-
139
- // TODO: remove when `next-auth/react` sends `X-Auth-Return-Redirect`
140
- const shouldRedirect = req . method === "POST" && req . headers . get ( "Content-Type" ) === "application/json" ? ( await req . clone ( ) . json ( ) ) . json : false
141
-
142
- // TODO: This can be directly in core
143
- const res = await AuthHandler ( req , args [ 0 ] )
144
- if ( req . headers . get ( "X-Auth-Return-Redirect" ) || shouldRedirect ) {
145
- const url = res . headers . get ( "Location" )
146
- res . headers . delete ( "Location" )
147
- return new Response ( JSON . stringify ( { url } ) , res )
148
- }
149
- return res
135
+ const envSecret = process . env . NEXTAUTH_SECRET
136
+ const envTrustHost = ! ! ( process . env . NEXTAUTH_URL ?? process . env . AUTH_TRUST_HOST ?? process . env . VERCEL ?? process . env . NODE_ENV !== "production" )
137
+ if ( args . length === 1 ) {
138
+ return ( req : Request ) => {
139
+ args [ 0 ] . secret ??= envSecret
140
+ args [ 0 ] . trustHost ??= envTrustHost
141
+ return AuthHandler ( req , args [ 0 ] )
150
142
}
143
+ }
144
+ args [ 1 ] . secret ??= envSecret
145
+ args [ 1 ] . trustHost ??= envTrustHost
151
146
return AuthHandler ( args [ 0 ] , args [ 1 ] )
152
147
}
153
148
154
- export default Auth ( authOptions )
149
+ // export default Auth(authOptions)
150
+
151
+ export default function handle ( request : Request ) {
152
+ return Auth ( request , authOptions )
153
+ }
155
154
156
155
export const config = { runtime : "experimental-edge" }
0 commit comments