Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit b0822df

Browse files
authored
Added documentation for API CORS settings
The explanation of how to use the CORS settings in laravel-echo-server.json file.
1 parent 6cc61f2 commit b0822df

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ List of users on a channel.
186186
GET /apps/:APP_ID/channels/:CHANNEL_NAME/users
187187
```
188188

189+
**Cross Domain Access To API**
190+
Cross domain access can be specified in laravel-echo-server.json file by changing `allowCors` in `apiOriginAllow` to `true`. You can then set the CORS origin domain you want to allow, the http allow methods as a comma separated string (only GET works since it's read only data, at least as of right now) and the allow headers to allow to the API to receive.
191+
192+
Example below:
193+
194+
``` json
195+
{
196+
"apiOriginAllow":{
197+
"allowCors" : true,
198+
"allowOrigin" : "http://127.0.0.1",
199+
"allowMethods" : "GET",
200+
"allowHeaders" : "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
201+
}
202+
}
203+
204+
```
205+
This allows you to ping the API via AJAX calls from your app that could be running on the same domain but different port or it could be entirely different domain.
206+
189207
## Database
190208

191209
To persist presence channel data, there is support for use of Redis or SQLite as a key/value store. The key being the channel name, and the value being the list of presence channel members.

0 commit comments

Comments
 (0)