Skip to content

Commit 78437c6

Browse files
authored
fix(copilot): send api key to sim agent (#1142)
* Fix api key auth * Lint
1 parent 3b74250 commit 78437c6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ Copilot is a Sim-managed service. To use Copilot on a self-hosted instance:
160160

161161
- Go to https://sim.ai → Settings → Copilot and generate a Copilot API key
162162
- Set `COPILOT_API_KEY` in your self-hosted environment to that value
163-
- Host Sim on a publicly available DNS and set NEXT_PUBLIC_APP_URL and BETTER_AUTH_URL to that value ([ngrok](https://ngrok.com/))
164163

165164
## Tech Stack
166165

apps/sim/app/api/copilot/api-keys/route.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export async function GET(request: NextRequest) {
1919

2020
const res = await fetch(`${SIM_AGENT_API_URL}/api/validate-key/get-api-keys`, {
2121
method: 'POST',
22-
headers: { 'Content-Type': 'application/json' },
22+
headers: {
23+
'Content-Type': 'application/json',
24+
...(env.COPILOT_API_KEY ? { 'x-api-key': env.COPILOT_API_KEY } : {}),
25+
},
2326
body: JSON.stringify({ userId }),
2427
})
2528

@@ -61,7 +64,10 @@ export async function DELETE(request: NextRequest) {
6164

6265
const res = await fetch(`${SIM_AGENT_API_URL}/api/validate-key/delete`, {
6366
method: 'POST',
64-
headers: { 'Content-Type': 'application/json' },
67+
headers: {
68+
'Content-Type': 'application/json',
69+
...(env.COPILOT_API_KEY ? { 'x-api-key': env.COPILOT_API_KEY } : {}),
70+
},
6571
body: JSON.stringify({ userId, apiKeyId: id }),
6672
})
6773

0 commit comments

Comments
 (0)