webapp: harden mapbox/chatwoot runtime config
Some checks failed
Build Docker Image / build (push) Failing after 13m29s
Some checks failed
Build Docker Image / build (push) Failing after 13m29s
This commit is contained in:
20
app/plugins/00-apollo-console-filter.client.ts
Normal file
20
app/plugins/00-apollo-console-filter.client.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
export default defineNuxtPlugin(() => {
|
||||
const originalConsoleError = console.error
|
||||
|
||||
console.error = (...args: unknown[]) => {
|
||||
const hasApolloDevtoolsWarning = args.some((arg) => {
|
||||
if (typeof arg !== 'string') return false
|
||||
|
||||
return (
|
||||
arg.includes('connectToDevTools') &&
|
||||
arg.includes('devtools.enabled')
|
||||
)
|
||||
})
|
||||
|
||||
if (hasApolloDevtoolsWarning) {
|
||||
return
|
||||
}
|
||||
|
||||
originalConsoleError(...args)
|
||||
}
|
||||
})
|
||||
@@ -1,8 +1,15 @@
|
||||
export default defineNuxtPlugin(() => {
|
||||
const config = useRuntimeConfig()
|
||||
const baseUrl = String(config.public.chatwootBaseUrl || '').trim()
|
||||
const websiteToken = String(config.public.chatwootWebsiteToken || '').trim()
|
||||
|
||||
if (!baseUrl || !websiteToken) {
|
||||
return
|
||||
}
|
||||
|
||||
const loadChatwoot = () => {
|
||||
if (document.getElementById('chatwoot-sdk')) return
|
||||
|
||||
const baseUrl = 'https://chatwoot.optovia.ru'
|
||||
const script = document.createElement('script')
|
||||
script.id = 'chatwoot-sdk'
|
||||
script.src = `${baseUrl}/packs/js/sdk.js`
|
||||
@@ -10,7 +17,7 @@ export default defineNuxtPlugin(() => {
|
||||
script.defer = true
|
||||
script.onload = () => {
|
||||
window.chatwootSDK?.run({
|
||||
websiteToken: 'bc668ge3hM5ZpPeUgGEV1ZU9',
|
||||
websiteToken,
|
||||
baseUrl
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user