-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Gemini dev server and serve 4.17 (#5199)
* Update dev server and use 4.17 * Add Node.js 16 requirements
- Loading branch information
Showing
6 changed files
with
752 additions
and
1,699 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import express from 'express'; | ||
import { createProxyMiddleware } from 'http-proxy-middleware'; | ||
import { join } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const { PORT = 5002 } = process.env; | ||
const DEFAULT_BOT_ID = 'webchat-mockbot'; | ||
|
||
const app = express(); | ||
|
||
app.get('/', async (_, res) => { | ||
const tokenRes = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' }); | ||
|
||
if (!tokenRes.ok) { | ||
return res.send(500); | ||
} | ||
|
||
const { token } = await tokenRes.json(); | ||
|
||
const redirectURL = new URL(DEFAULT_BOT_ID, 'http://localhost/embed/'); | ||
|
||
redirectURL.searchParams.set('b', DEFAULT_BOT_ID); | ||
redirectURL.searchParams.set('t', token); | ||
|
||
res.status(302); | ||
res.header('location', redirectURL.pathname + redirectURL.search); | ||
|
||
return res.end(); | ||
}); | ||
|
||
app.get('/embed/:bot', async (_, res) => | ||
res.setHeader('content-type', 'text/html').sendFile(join(fileURLToPath(import.meta.url), '../dist/gemini.html')) | ||
); | ||
|
||
app.get('/embed/:bot/config', createProxyMiddleware({ changeOrigin: true, target: 'https://webchat.botframework.com/' })); | ||
|
||
app.listen(PORT, () => console.log(`Embed dev server is listening to port ${PORT}`)); |
Oops, something went wrong.