diff --git a/src/komponenter/footer/chatbot/ChatbotWrapper.tsx b/src/komponenter/footer/chatbot/ChatbotWrapper.tsx index 0acdffd9f..776f85a31 100644 --- a/src/komponenter/footer/chatbot/ChatbotWrapper.tsx +++ b/src/komponenter/footer/chatbot/ChatbotWrapper.tsx @@ -40,9 +40,15 @@ export const ChatbotWrapper = () => { const [scriptLoaded, setScriptLoaded] = useState(false); const currentFeatureToggles = useSelector(stateSelector).featureToggles; + const isLocal: boolean = env === 'localhost'; const isProduction = env === 'prod'; const boostApiUrlBase = isProduction ? boostApiUrlBaseProduction : boostApiUrlBaseTest; + const cookieSettings = { + path: '/', + domain: isLocal ? 'localhost' : '.nav.no', + }; + const openBoostWindow = () => { if (typeof boost !== 'undefined') { boost.chatPanel.show(); @@ -122,14 +128,14 @@ export const ChatbotWrapper = () => { boost.chatPanel.addEventListener('conversationIdChanged', (event: any) => { if (!event?.detail?.conversationId) { - removeCookie(conversationCookieName); + removeCookie(conversationCookieName, cookieSettings); return; } const expirationDay = new Date(); expirationDay.setHours(expirationDay.getHours() + 1); setCookie(conversationCookieName, event.detail.conversationId, { expires: expirationDay, - domain: isProduction ? '.nav.no' : '.dev.nav.no', + ...cookieSettings, }); }); boost.chatPanel.addEventListener('setFilterValue', function (ev: any) { @@ -137,7 +143,7 @@ export const ChatbotWrapper = () => { if (ev.detail.nextId) boost.chatPanel.triggerAction(ev.detail.nextId); }); boost.chatPanel.addEventListener('chatPanelClosed', () => { - removeCookie(conversationCookieName); + removeCookie(conversationCookieName, cookieSettings); }); if (bufferLoad) {