Skip to content

Commit

Permalink
chore: Proxy mattermost webhook handler in dev (#10503)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch authored Nov 20, 2024
1 parent f49c4e5 commit d390ae4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {createVerifier, httpbis} from 'http-message-signatures'
import {markdownToDraft} from 'markdown-draft-js'
import {Variables} from 'relay-runtime'
import {HttpRequest, HttpResponse} from 'uWebSockets.js'
import appOrigin from '../../appOrigin'
import AuthToken from '../../database/types/AuthToken'
import uWSAsyncHandler from '../../graphql/uWSAsyncHandler'
import parseBody from '../../parseBody'
Expand All @@ -10,10 +11,6 @@ import getGraphQLExecutor from '../../utils/getGraphQLExecutor'
import sendToSentry from '../../utils/sendToSentry'

const MATTERMOST_SECRET = process.env.MATTERMOST_SECRET
const PORT = __PRODUCTION__ ? process.env.PORT : process.env.SOCKET_PORT
const HOST = process.env.HOST
const PORT_SUFFIX = HOST !== 'localhost' ? '' : `:${PORT}`
const ORIGIN = `${process.env.PROTO}://${HOST}${PORT_SUFFIX}`

const markdownToDraftJS = (markdown: string) => {
const rawObject = markdownToDraft(markdown)
Expand Down Expand Up @@ -330,7 +327,7 @@ const mattermostWebhookHandler = uWSAsyncHandler(async (res: HttpResponse, req:
},
{
method: req.getMethod(),
url: ORIGIN + req.getUrl(),
url: appOrigin + req.getUrl(),
headers
}
)
Expand Down
2 changes: 2 additions & 0 deletions scripts/webpack/dev.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
},
stats: 'errors-warnings',
devServer: {
allowedHosts: ['localhost', 'host.docker.internal'],
client: {
logging: 'warn'
},
Expand Down Expand Up @@ -57,6 +58,7 @@ module.exports = {
'graphql',
'intranet-graphql',
'self-hosted',
'mattermost',
// important terminating / so saml-redirect doesn't get targeted, too
'saml/'
].map((name) => ({
Expand Down

0 comments on commit d390ae4

Please sign in to comment.