I send a post request to YAWS server using AJAX from a different port/domain but javascript returns this error message:
XMLHttpRequest cannot load http://0.0.0.0:8000/index.yaws. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
Now I understand that I need to include CORS headers in index.yaws file but I don't know how to do it in Erlang
.
If you want to set only
localhost
as an allowed origin you could try the code below. Note that it represents the JSON results you currently return with the variableYourJsonString
.