Skip to content

Commit 4771e76

Browse files
Update README with CORS explanation
1 parent 905c8b9 commit 4771e76

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.markdown

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ module API
3333
end
3434
```
3535

36-
To explore your API, either download [Swagger UI](https://github.com/wordnik/swagger-ui) and set it up yourself or go to the [online swagger demo](http://petstore.swagger.wordnik.com/) and enter your localhost url documentation root in the url field (probably something in the line of http://localhost:3000/swagger_doc.json)
36+
To explore your API, either download [Swagger UI](https://github.com/wordnik/swagger-ui) and set it up yourself or go to the [online swagger demo](http://petstore.swagger.wordnik.com/) and enter your localhost url documentation root in the url field (probably something in the line of http://localhost:3000/swagger_doc.json).
37+
If you use the online demo, make sure your API supports foreign requests by enabling CORS in grape, otherwise you'll see the API description, but requests on the API won't return. You can do this by putting below code in your Grape API definition:
38+
39+
```` ruby
40+
before do
41+
header['Access-Control-Allow-Origin'] = '*'
42+
header['Access-Control-Request-Method'] = '*'
43+
end
44+
````
3745

3846
## Configure
3947
You can pass a hash with some configuration possibilities to ```add_swagger_documentation```, all of these are optional:

0 commit comments

Comments
 (0)