I think you need to set appropriate headers, doing so in Jester is trivial (didn't test this but should work):
routes:
get "/":
resp Http200, {"Access-Control-Allow-Origin": "http://www.example.com"}, "Content"
(Source: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
routes:
get re"/(.*)":
cond request.matches[0].splitFile.ext == ""
resp(Http200, {"Access-Control-Allow-Origin":"*"}, readFile("index.html"))
post "/login":
var body = parseJson request.body()
var name = body["name"].getStr
var password = body["password"].getStr
var target = db.getValue(sql SELECT "password".FROM "user".WHERE"name=?", name)
if password != "" and password == target:
resp(Http200, {"Access-Control-Allow-Origin":"*"},"success")
seems doesn't solve this problem, do we literally need {"Access-Control-Allow-Origin":"*"} for every response?template corsResp(code, message: untyped): untyped =
mixin resp
resp code, {"Access-Control-Allow-Origin": "*"}, message
Some templating magic for this, haven't tested though.
Why doesn't my code work? It's the same with
resp(Http200, {"Access-Control-Allow-Origin":"*"} ,"ok")