The free live chat script Tawk.to is encountering a 400 Bad Request Error

After setting up a free live chat service from tawk.to, I encountered a frustrating issue. Unfortunately, there is no customer support available for this script and it keeps generating a '400 Bad Request' error when trying to connect to the tawk.to servers. I attempted to fix this by adding different origin codes to my .htaccess file, but even that did not solve the problem - the error persisted. It seems like I have hit a dead end and I'm unsure of what steps to take next.

I experimented with the following lines in my .htaccess file, but they didn't make any difference:

SetEnvIf Origin "^(.*\.tawk\.to)$" ORIGIN_SUB_DOMAIN=$1
Header set Access-Control-Allow-Origin "%{ORIGIN_SUB_DOMAIN}e" env=ORIGIN_SUB_DOMAIN

Access-Control-Allow-Origin: *.tawk.to

The response header (assuming the script is on EXAMPLE.com):

Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Encodinggzip, deflate, brAccept-Languageen-US,en;q=0.5Cache-Controlno-cacheConnectionkeep-alive, UpgradeCookie__tawkuuid=e::tawk.to::CZ4miEdTw+LJy27l6cezd/vgJ1Go/uVCmU/4mrr+WIe5uNur3LjRp6TAhWSTCS83::2; __cfduid=d8cf244362c2ead0f846b52cd84058bd31488522157DNT1

Host vs51.tawk.to

Origin https://EXAMPLE.com

Pragmano-cacheSec-WebSocket-Extensionspermessage-deflateSec-WebSocket-KeyBPkRsxjD+iWVmfb3LV8zpA==Sec-WebSocket-Version13UpgradewebsocketUser-AgentMozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0

The Error Response:

GET https://vs51.tawk.to/s/ [HTTP/1.1 400 Bad Request 162ms]

Here is an example JavaScript snippet provided by tawk.to which includes the 'crossorigin'* attribute, although it still triggers the error:

<!--Start of Tawkto (example)-->
<script>
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/0111111111/default';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawkto-->

Answer №1

After reaching out to [email protected] without success, I took it upon myself to do some more digging. It turns out that several websites using tawk.to chat are also experiencing the 400 Bad Request error, indicating that this issue is likely a problem with the tawk.to script itself. Unfortunately, it seems that this problem has yet to be resolved, leaving all of their customers affected.

Answer №2

You may have noticed that some countries are being blocked in your tawkto account widget. I suggest turning off the country blocking feature on your widget to see if it resolves the issue. This solution has worked for me in the past.

https://i.sstatic.net/UxxoQ.png

Answer №3

Encountered a similar issue, but managed to find a solution. Make sure to consider the following factors:

  • Include a userId when making the call
  • The hash should be a lowercase combination of the userId and Api Key

Below is a sample code snippet: (Note that this code is not executable as-is, you need to input your own variables for it to function properly, but I was able to successfully enable user logins)

var isLoggedIn = false;
var Tawk_API = {
  onLoad: function() {
    if (!isLoggedIn) {
      isLoggedIn = true;
      window.Tawk_API.login({
        hash: '{{Put your Hash here}}',
        name: '{{User Name}}',
        email: '{{User Email}}',
        userId: '{{User ID}}'
      }, function(error) {
        //handle error response
      });
    }
  }
};
var Tawk_LoadStart = new Date();
(function() {
  var s1 = document.createElement("script"),
    s0 = document.getElementsByTagName("script")[0];
  s1.async = true;
  s1.src = '{{Put your Chat Link here}}';
  s1.charset = 'UTF-8';
  s1.setAttribute('crossorigin', '*');
  s0.parentNode.insertBefore(s1, s0);
})();

Answer №4

Need help resolving the dreaded 400 bad request issue with your domain? A quick fix is to simply append a * at the end of your URL if domain restriction is enabled.

For example: https://www.example.com/*

https://i.sstatic.net/P8z2l.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to utilize a parameter value as the name of an array in Jquery

I am encountering an issue with the following lines of code: $(document).ready(function () { getJsonDataToSelect("ajax/json/assi.hotel.json", '#assi_hotel', 'hotelName'); }); function getJsonDataToSelect(url, id, key){ ...

Error: An error was detected due to a missing closing parenthesis after an argument list while attempting to utilize

Attempting to condense a string using the LZMA-JS library available here. This is how my javascript code looks: var reader = new FileReader(); reader.addEventListener("load", function () { var big_code = reader.result; console.log(big_code.lengt ...

How to enhance precision by adding decimal places using JavaScript

I have an integer number 439980. I want to add a decimal point two places from the right, so it becomes 4399.80. The length of the number can vary, but I always need it to show two decimal places from the right. Any suggestions on how I can achieve this ...

Use Ajax to send a standard image as a response

Hello everyone, I am wondering how to convert an image to an object in the following code: var img = $('<img id="dynamic">'); img.attr('src', 'http://macreationdentreprise.fr/wp-content/uploads/2012/06/ouvrir-un-restaurant. ...

What is the best way to extract a value from a string containing a list of maps?

I am currently facing a requirement where I need to extract values from a map in the following format: "{xyz=True, abc=asd-1123, uvw=null}" The challenge is to retrieve these values from a string representation of the map. I have attempted usi ...

Unable to retrieve information stored in an object within a Vue component

I'm having trouble accessing the data within the user object. { "channel_id": 2, "user": { "id": 1, "name": "Clyde Santiago", "email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="187c7d606c7d6a7c7d6e28 ...

Automating user login with node.js and passport.js: A step-by-step guide

My login application is built using node.js and passport.js, with the session being maintained using express-session and connect-mongo. I need to ensure that users are redirected to the home page upon accessing the URL, only sending them to the login page ...

Test a JavaScript function within an Angular service using the Jasmine framework

I need to write a unit test for a JavaScript function within an Angular service using Jasmine. Here is the Angular service: angular.module("app.services").service("validationService", ["$q", function ($q) { this.validate = function (filter): ng. ...

IE9 not executing AngularJS filter

Currently, I am encountering an issue with my custom filter in AngularJS 1.2.22 on IE9. Interestingly, the filter works perfectly fine on Chrome and Firefox, but unfortunately not on the browser that is essential for me. The problem lies within two filter ...

Removing exclamation points from the routing of a state URL is a key aspect of mastering full stack development

Is there a way to remove exclamation marks from the url in state routing using mean.io? Currently, my url looks like http://localhost:3000/#!/auth/register I just want to get rid of the "!" marks after the "#" symbol. Is it possible? Here is the content ...

How do I create a notification when the div reaches 100% alignment on the left side using Javascript?

Is there a way to receive an alert when the div with the class name "earth" reaches 100% on the left side, without using jQuery? I attempted to utilize setTimeout but I am looking for an alternative method that does not rely on time, but rather on positi ...

What is the best method to ensure that none of the select option values are left empty?

I have a total of 5 select option drop down menus currently, but this number may increase in the future depending on requirements. The issue I'm facing is that when I select the last element, it returns true even though the other elements are empty. I ...

"Error handling in React AJAX post requests is not triggering the success or error methods as expected

Within my React Component, there is an AJAX POST request that successfully creates a new entry in the database (status 201 returned). However, I am facing an issue where the success and error methods are not being triggered. $.ajax({ url: &apo ...

Adjust the container size based on changes in font size

One interesting issue I encountered involves displaying each word in a sentence in separate div elements using inline-block with a max-width of 120px. When attempting to increase the font size within the parent div, the inline-block divs begin to overlap d ...

Navigating through an array of functions, some of which may return promises while others do not

Is there a way to efficiently iterate and execute an array of functions where some return promises, requiring the use of await, while most do not return promises, necessitating them to be set as async? for (let i = 0; i < this.steps.length; i++) { ...

Exploring the fundamentals of Express.js code base

I have been examining the express.js code and attempting to rewrite it to gain a better understanding of creating middlewares within a framework. However, the complex inheritance structure in the code is causing confusion for me. Here are some relevant co ...

The Telegram Login component is not displaying properly within a React single-page application

I am currently working on a React frontend application that was created using create-react-app, with Django running at the backend. We have separate development and production environments, each with its own domain. My goal now is to integrate a widget int ...

What could be causing the onClick event handler to trigger twice in my create-react-app?

Does anyone know why the "upvote" onClick handler is triggering twice? Even though the logs show it's only running once, the score increases by 2 export default class Container extends Component { constructor(props) { super(props); this.sta ...

Tips for wrapping text to fit the width of a column

Hello, I have a table with varying column widths as shown below ${"#goldBarList"} table tr td:first-child{width:5%;} ${"#goldBarList"} table tr td:first-child+td{width:5%;} ${"#goldBarList"} table tr td:first-child+td+td{width:6%;} ${"#goldBarList"} table ...

In search of a tool that enables horizontal scrolling of content

I am on the lookout for a piece of Javascript code that can be integrated into my website to enable me to horizontally scroll content either from left to right or right to left. Although I found this script here: It offers the fundamental functionality th ...