Cookiebot is breaking angular Angular HttpClient subscribe
Hello there,
Our client is using cookiebot on his sites and we faced and issue that is happening when user accepts only "Necessary" cookies. This problem occurs only when "Necessary" option is selected, and is not happening if all cookies are accepted.
We have noticed that after "Necessary" cookies are accepted, subscribe on Angular HttpClient get, post and other methods is never executed. Problem is solved if page is reloaded.
Here is code example:
this.http.get<string[]>('some/api/users', httpOptions)
.subscribe(res => {
// NEVER GET INSIDE!
this.users = res;
});
I have created simple PoC application that is demonstrating this behavior and can be accessed here: https://cookiebot-poc.herokuapp.com/mobapp/
Working scenario:
1. Clean cookies (or open incognito)
2. Open https://cookiebot-poc.herokuapp.com/mobapp/
3. Accept "all" cookies
4. Click "Do Get" or "Do Post" button
5. Request is send, and list with users are displayed on screen
Issue reproduction scenario:
1. Clean cookies (or open incognito)
2. Open https://cookiebot-poc.herokuapp.com/mobapp/
3. Accept "Necessary" cookies only
4. Click "Do Get" or "Do Post" button
5. Nothing happens
Thank you.
-
Hi,
any news on this issue?
I have the same issue, subscribe is not raised after successful HTTP request (it returns HTTP status 200 + data, the only cookie in this request is Cookiebot cookie, but subscribe fnc is not raised with any error message).
I use Angular 11.
I don't use any cookies.
In my case I have to allow all cookies - when some of cookies are disabled then subscribe fnc is not raised.
In addition, Cookiebot settings can not be changed when some cookies are disabled (I call Cookiebot.renew() method, but it does nothing, user has to reload page (F5) and then can change Cookiebot settings or it does work without F5 when all cookies are enabled).
Thank you.
0 -
Our client is using a cookie bot on his sites, and we faced an issue when the user accepts only "Necessary" cookies. This problem occurs only when the "Necessary" option is selected and is not happening if all cookies are accepted.
We have noticed that after "Necessary" cookies are accepted, subscribe on Angular HttpClient get, post and other methods are never executed. The problem is solved if the page is reloaded.
0 -
Try
<script type="text/javascript"> function CookiebotCallback_OnLoad() { Cookiebot.changed && document.location.reload(); } </script>
0 -
Hi,
I solved this by removing data-blockingmode="auto" from Cookiebot-init script in index.html
This is the answer from Cookiebot support:
Angular app brokes when Automatic Blocking Mode is enabled, which we highly advocate against, when using the Angular framework.
The reason for the above is that our auto blocker takes control of the Document Object Model (DOM), when matching the objects listed in
configuration.js
- the file we use to withhold/block scripts before the user has given consent. Now, Angular also needs to have control over the DOM to function properly, so, by enabling our auto blocker you have a clear conflict at hand here.
On the opposite, Manual Blocking Mode does not utilize the DOM, thus the Angular is allowed to function without issues (hopefully).Regards
Pavel0
Please sign in to leave a comment.
Comments
4 comments