@fonsp I am able to successfully communicate between my development front-end and development Julia servers (which is great), but I am getting a CORS error when I try and fetch:
Access to fetch at 'http://127.0.0.1:8000/random' from origin
'http://localhost:3000' has been blocked by CORS policy:
The 'Access-Control-Allow-Origin' header contains the invalid value ''.
Have the server send the header with a valid value, or, if an opaque
response serves your needs, set the request's mode to 'no-cors'
to fetch the resource with CORS disabled.
routes.jl
using Genie, Genie.Router, Genie.Renderer.Json, Genie.Requests
using HTTP
Genie.config.run_as_server = true
Genie.config.cors_allowed_origins = ["*"]
route("/random", method="POST") do
dim = parse(Int, get(@params, :dim, "2"))
num = parse(Int, get(@params, :num, "3"))
(:random => rand(dim,num)) |> json
end
Genie.startup()
relevant App.js
let params = {
dim: '1',
num: '3'
}
const url = 'http://127.0.0.1:8000/random'
fetch(url, {
method: 'POST',
mode: "cors",
body: params
})
.then(response => response.json())
.then(data => console.log(data))
.catch(()=>console.log('Wade- you cant access the url response'));