Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ CLIENT_ID=
CLIENT_SECRET=
ORGANIZATION_ID=
WORKSPACE_ID=
ALLOWED_ORIGIN=
BASE_URL=
```

Expand Down
3 changes: 3 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<title>Airbyte Embedded Widget</title>
</head>
<body>
<h1>Airbyte Embedded Widget</h1>
<div id="widget-container"></div>

<script type="module">
Expand Down Expand Up @@ -36,6 +37,8 @@
token: data.token,
onEvent: widgetResultCallback,
});

widget.mount("#widget-container");
} catch (err) {
console.error("Failed to load widget:", err);
}
Expand Down
13 changes: 9 additions & 4 deletions demo/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ const AIRBYTE_ACCESS_TOKEN_URL = `${BASE_URL}/v1/applications/token`;
const CLIENT_ID = process.env.CLIENT_ID;
const CLIENT_SECRET = process.env.CLIENT_SECRET;
const WORKSPACE_ID = process.env.WORKSPACE_ID;
const ORGANIZATION_ID = process.env.ORGANIZATION_ID;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was not used

const ALLOWED_ORIGIN = process.env.ALLOWED_ORIGIN || "http://localhost:3000";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be inferred!


// GET /api/widget → fetch widget token and return it
app.get("/api/widget_token", async (req, res) => {
try {
// Determine the allowed origin from the request
const origin =
req.headers.origin ||
req.headers.referer?.replace(/\/$/, "") ||
process.env.ALLOWED_ORIGIN ||
"http://localhost:3000";

const access_token_body = JSON.stringify({
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
Expand Down Expand Up @@ -66,8 +71,7 @@ app.get("/api/widget_token", async (req, res) => {
},
body: JSON.stringify({
workspaceId: WORKSPACE_ID,
organizationId: ORGANIZATION_ID,
allowedOrigin: ALLOWED_ORIGIN,
allowedOrigin: origin,
}),
});

Expand All @@ -78,6 +82,7 @@ app.get("/api/widget_token", async (req, res) => {
}

const widget_token = await widget_token_response.text();

res.json({ token: widget_token });
} catch (err) {
console.error("Unexpected error:", err);
Expand Down
Loading
Loading