Detect host from list of allowed urls even if they have http/https

This commit is contained in:
Ilango 2024-03-05 17:23:49 +05:30
parent d0ddf018c7
commit d706ca389f
2 changed files with 6 additions and 5 deletions

View File

@ -1332,7 +1332,11 @@ export class App {
if (parsedConfig.allowedOrigins && parsedConfig.allowedOrigins.length > 0 && isValidAllowedOrigins) {
const originHeader = req.headers.origin as string
const origin = new URL(originHeader).host
isDomainAllowed = parsedConfig.allowedOrigins.includes(origin)
isDomainAllowed =
parsedConfig.allowedOrigins.filter((domain: string) => {
const allowedOrigin = new URL(domain).host
return origin === allowedOrigin
}).length > 0
}
}

View File

@ -145,10 +145,7 @@ const AllowedDomainsDialog = ({ show, dialogProps, onCancel, onConfirm }) => {
flexDirection: 'column'
}}
>
<span>
Your chatbot will only work when used from the following domains. When adding domains, exclude the{' '}
<pre style={{ display: 'inline' }}>http://</pre> or <pre style={{ display: 'inline' }}>https://</pre> part.
</span>
<span>Your chatbot will only work when used from the following domains.</span>
</div>
<Box sx={{ '& > :not(style)': { m: 1 }, pt: 2 }}>
<List>