We got it.

Basically, we made a silly mistake in the "# Messy route handling here". We 
were creating new responses that overrode the headers we set.

using HttpServer
using JSON

http = HttpHandler() do req::Request, res::Response

# Messy route handling here

 

res.headers["Access-Control-Allow-Origin"] = "*"
res
end

server = Server(http)
run(server, 8000)


We simply needed to set the header to allow access at the end.

It works now. Yay!


On Friday, September 18, 2015 at 12:39:00 PM UTC+8, Eric Forgy wrote:
>
> Hi,
>
> I am having some trouble getting CORS to work. I have a simple Julia 
> server on an Azure VM. If I navigate to the URL, I can see the response I 
> expect, but I am now trying to get this to work cross origin.
>
> I tried the following, but it is not working:
>
>     using HttpServer
>     using JSON
>     import Requests
>     
>     http = HttpHandler() do req::Request, res::Response
> res.headers["Access-Control-Allow-Origin"] = "*"
>      
>     # Messy route handling here.
>  
>     end
>     server = Server(http)
>     run(server, 8000)
>
> Any suggestions? Thanks!
>

Reply via email to