-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite-proxy-routes.ts
More file actions
122 lines (120 loc) · 3.51 KB
/
vite-proxy-routes.ts
File metadata and controls
122 lines (120 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* Vite Proxy Routes Configuration
*
* Static proxy route definitions for the Vite dev server.
* This file is imported by vite.config.ts and must NOT use @/ path aliases
* since those aren't available when the Vite config is being processed.
*
* These routes enable OAuth token exchange and API proxying during development.
* The production build uses the bridge server directly.
*/
import type { ProxyRoute } from './src/lib/oauth-proxy-plugin'
/**
* Get all proxy routes for the OAuth proxy plugin.
* Each route defines how to proxy API requests and inject credentials.
*
* @param env - Environment variables from loadEnv()
*/
export function getProxyRoutes(env: Record<string, string>): ProxyRoute[] {
return [
// Google OAuth (shared by all Google providers: Drive, Gmail, Calendar, Meet, Tasks, Chat)
{
pathPrefix: '/api/google',
pathMatch: '/token',
target: 'https://oauth2.googleapis.com',
credentials: {
type: 'body',
clientId: env.VITE_GOOGLE_CLIENT_ID || '',
clientSecret: env.VITE_GOOGLE_CLIENT_SECRET || '',
},
},
// Notion OAuth
{
pathPrefix: '/api/notion',
pathMatch: '/oauth/token',
target: 'https://api.notion.com',
targetPathPrefix: '/v1',
credentials: {
type: 'basic-auth',
clientId: env.VITE_NOTION_CLIENT_ID || '',
clientSecret: env.VITE_NOTION_CLIENT_SECRET || '',
},
},
// Microsoft OAuth (Outlook, OneDrive)
{
pathPrefix: '/api/microsoft',
pathMatch: '/token',
target: 'https://login.microsoftonline.com/common',
credentials: {
type: 'body',
clientId: env.VITE_MICROSOFT_CLIENT_ID || '',
clientSecret: env.VITE_MICROSOFT_CLIENT_SECRET || '',
},
},
// Dropbox OAuth
{
pathPrefix: '/api/dropbox',
pathMatch: '/token',
target: 'https://api.dropboxapi.com',
credentials: {
type: 'body',
clientId: env.VITE_DROPBOX_CLIENT_ID || '',
clientSecret: env.VITE_DROPBOX_CLIENT_SECRET || '',
},
},
// Qonto OAuth
{
pathPrefix: '/api/qonto/oauth',
pathMatch: '/oauth2/token',
target: 'https://oauth.qonto.com',
credentials: {
type: 'body',
clientId: env.VITE_QONTO_CLIENT_ID || '',
clientSecret: env.VITE_QONTO_CLIENT_SECRET || '',
},
},
// Qonto API
{
pathPrefix: '/api/qonto/v2',
target: 'https://thirdparty.qonto.com',
targetPathPrefix: '/v2',
credentials: { type: 'none' },
},
// Slack OAuth
{
pathPrefix: '/api/slack',
pathMatch: '/oauth.v2.access',
target: 'https://slack.com/api',
credentials: {
type: 'body',
clientId: env.VITE_SLACK_CLIENT_ID || '',
clientSecret: env.VITE_SLACK_CLIENT_SECRET || '',
},
},
// Figma OAuth
{
pathPrefix: '/api/figma',
pathMatch: '/token',
target: 'https://api.figma.com',
credentials: {
type: 'body',
clientId: env.VITE_FIGMA_CLIENT_ID || '',
clientSecret: env.VITE_FIGMA_CLIENT_SECRET || '',
},
},
// Skills.sh API (unauthenticated, CORS proxy only)
{
pathPrefix: '/api/skills',
target: 'https://skills.sh',
targetPathPrefix: '/api',
credentials: { type: 'none' },
},
// ChatJimmy API (unauthenticated, CORS proxy only)
{
pathPrefix: '/api/chatjimmy',
target: 'https://chatjimmy.ai',
targetPathPrefix: '/api',
credentials: { type: 'none' },
},
]
}