Found the answer to my problem here. “application/json” is only a valid content type with CORS.
Now my problem is how to configure CORS in my phoenix api. I’m using cors_plug. But is not working, I’m still getting in my request.
Access to fetch at 'http://localhost:4000/v1/users/signup' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
This is my CORS config in router.ex file
defmodule DumyApiWeb.Router do
use DummyApiWeb, :router
...
pipeline :v1 do
plug CORSPlug, origin: "http://localhost:8080"
plug DummyApiWeb.Version, version: :v1
end
...
scope "/v1", DummyApiWeb do
pipe_through :v1
post "/users/signup", UserController, :create
post "/users/signin", UserController, :signin
end
...
end






















