Skip to content

Commit e268bfb

Browse files
committed
fix(auth): reorder CORS headers and handle missing redirectURI
1 parent 39566a1 commit e268bfb

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

apps/sim/app/(auth)/oauth/consent/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ export default function OAuthConsentPage() {
8787
const data = (await res.json()) as { redirectURI?: string }
8888
if (data.redirectURI) {
8989
window.location.href = data.redirectURI
90+
} else {
91+
setError('The server did not return a redirect. Please try again.')
92+
setSubmitting(false)
9093
}
9194
} catch {
9295
setError('Something went wrong. Please try again.')

apps/sim/next.config.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,26 @@ const nextConfig: NextConfig = {
129129
{ key: 'Access-Control-Allow-Headers', value: 'Content-Type, Accept' },
130130
],
131131
},
132+
{
133+
// API routes CORS headers
134+
source: '/api/:path*',
135+
headers: [
136+
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
137+
{
138+
key: 'Access-Control-Allow-Origin',
139+
value: env.NEXT_PUBLIC_APP_URL || 'http://localhost:3001',
140+
},
141+
{
142+
key: 'Access-Control-Allow-Methods',
143+
value: 'GET,POST,OPTIONS,PUT,DELETE',
144+
},
145+
{
146+
key: 'Access-Control-Allow-Headers',
147+
value:
148+
'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, X-API-Key, Authorization',
149+
},
150+
],
151+
},
132152
{
133153
source: '/api/auth/oauth2/:path*',
134154
headers: [
@@ -156,26 +176,6 @@ const nextConfig: NextConfig = {
156176
{ key: 'Access-Control-Allow-Headers', value: 'Content-Type, Accept' },
157177
],
158178
},
159-
{
160-
// API routes CORS headers
161-
source: '/api/:path*',
162-
headers: [
163-
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
164-
{
165-
key: 'Access-Control-Allow-Origin',
166-
value: env.NEXT_PUBLIC_APP_URL || 'http://localhost:3001',
167-
},
168-
{
169-
key: 'Access-Control-Allow-Methods',
170-
value: 'GET,POST,OPTIONS,PUT,DELETE',
171-
},
172-
{
173-
key: 'Access-Control-Allow-Headers',
174-
value:
175-
'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, X-API-Key, Authorization',
176-
},
177-
],
178-
},
179179
// For workflow execution API endpoints
180180
{
181181
source: '/api/workflows/:id/execute',

0 commit comments

Comments
 (0)