Skip to content
This repository was archived by the owner on Jan 27, 2024. It is now read-only.

Commit 3e4c076

Browse files
committed
added help for CORS when invoking /services/apexrest endpoint
1 parent 2c357a1 commit 3e4c076

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ Find the `<c:lc_api>` by its `aura:id` then call the `restRequest(..)` method pa
6060
})
6161
```
6262

63+
# Troubleshooting
64+
65+
## "Access Denied" or "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://yourinstance.visualforce.com' is therefore not allowed access."
66+
67+
Your request was blocked due to [Cross-Origin Resource Sharing (CORS) policy](https://help.salesforce.com/articleView?id=extend_code_cors.htm&type=5).
68+
69+
This can happen when trying to make a request to `/services/apexrest/` endpoint.
70+
For example, the Visualforce domain hosting `LC_APIPage` is on `https://yourinstance.visualforce.com` and is trying to make a web request to `https://yourinstance.my.salesforce.com/services/apexrest/`.
71+
Because the two domains do not match, then CORS policy prevents the request.
72+
73+
1. In **Setup**, navigate to **Security | CORS**.
74+
75+
2. Add the origin URL mentioned in your error message (e.g. `https://yourinstance.visualforce.com`) to the list of whitelisted domains.
76+
77+
6378
# Credits
6479

6580
[Doug Ayers](https://douglascayers.com) develops and maintains the project.

0 commit comments

Comments
 (0)