Weglot and CORS Policies
In this article, you'll learn more about CORS Policies and how to solve potential issues related to them and Weglot.
What are CORS Policies?
To begin with, CORS is short for cross-origin resource sharing.
This mechanism is used to add HTTP headers. When added, it allows a user agent to access resources on a specific server that doesn't have the same origin as the website used.
The user agent makes HTTP cross-origin requests to access the resources coming from a specific domain. However, if this user agent is not authorized because the corresponding HTTP headers have not been added, it will not access the resources it needs.
For example, when a website is hosted on a specific server, it can load images from this server as well. However, it can also load images and assets coming from another web server, which is a cross-origin request. CORS controls this.
These cross-origin requests can provoke security issues, especially when exchanging data between browsers and servers that have a different origin from the original one used for the website.
If you want to know more about CORS and its technical aspects, please refer to the following documentation.
How can CORS policies potentially block Weglot?
Weglot requests the website to get its content and translate it. But if CORS policies do not authorize the Weglot API, the request will be blocked, and the website will not be translated.
If the user agent used by Weglot is also not authorized, it can provoke issues, such as blocking our Visual Editor and our Switcher Editor.
How to deal with potential issues?
Before you proceed, it is first important to understand the concept of whitelisting.
Whitelisting is the process of informing an element that a specific source, origin, or other element is authorized to perform a particular action. This element is then added to a list called a whitelist.
To deal with the potential issues linked to CORS Policies that you may face, you can contact your host provider and ask to whitelist the following: api.weglot.com, weglot.com, weglot.io, dashboard.weglot.com, and also allow our user-agent WeglotBot/1.0 (compatible; Mozilla/5.0; + https://weglot.com/) related to the Visual Editor.
That way, it will be indicated that these origins are allowed.
What is a hosting provider?
The hosting provider allows individuals or bigger organizations to access resources coming from the Internet through its connection to several servers.
Thanks to these providers, individuals or organizations can create and deploy their own websites on the World Wide Web. They provide storage space, maintain the connection to the Internet, and help manage the website design and database.
The web hosting provider's users also have access to a DNS (Domain Name System) configuration. With this access, they can configure their website to point directly to the hosting provider.
If you'd like to learn more about the hosting provider, please consult the following article.
Some of the well-known web hosting providers include Ionos, GoDaddy, DreamHost, Hostinger, and Bluehost.
If you continue having trouble with CORS Policies despite the abovementioned solutions, do not hesitate to contact us at support@weglot.com.