Fix CORS errors “Access-Control-Allow-Origin missing” (Plesk/LiteSpeed)
- 20.02.2026 00:58
-
- hosting
- litespeed
- plesk
- troubleshooting
If your browser console shows errors like:
Access to fetch at 'https://api.example.com' from origin 'https://example.com' has been blocked by CORS policyNo 'Access-Control-Allow-Origin' header is present
…your server is not sending the required CORS headers. CORS must be fixed on the server that receives the request (usually your API), not on the website that calls it.
Step 1 – Identify which URL is failing
- Open Developer Tools → Console/Network and copy the failing request URL.
- Check whether that URL is hosted on GARMTECH (Plesk) or on a third-party platform. If it’s third‑party, you must configure CORS there.
Step 2 – Decide what should be allowed (keep it strict)
For security, allow only the specific origins you need (for example, https://example.com and https://www.example.com).
Do not use * (wildcard) if you send cookies/Authorization headers (credentials).
Step 3 – Add CORS headers on GARMTECH Hosting (Plesk / LiteSpeed)
On GARMTECH Hosting (LiteSpeed), standard Apache-style .htaccess rules are supported.
Option A – Add headers in .htaccess (common case)
- In Plesk, open Files for the domain.
- Open the directory that serves the API (often
httpdocsor a subfolder). - Create or edit the file
.htaccess. - Add (example):
<IfModule mod_headers.c>
Header always set Access-Control-Allow-Origin "https://example.com"
Header always set Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type, Authorization"
</IfModule>
Handle preflight (OPTIONS) requests
Many APIs require an OPTIONS response for “preflight” checks. If your application does not handle OPTIONS, you can add a simple rule:
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=204,L]
Note: Some frameworks must handle preflight inside the application. If the rule above does not work, configure OPTIONS handling in your API code.
Step 4 – Test again
- Clear browser cache or test in an incognito window.
- Verify that the response now includes
Access-Control-Allow-Origin.
Common mistakes
- Adding headers on the wrong server (website instead of API).
- Using
*together withAccess-Control-Allow-Credentials: true(this is not allowed by browsers). - Forgetting to include
OPTIONSin allowed methods.