作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的前端是一个单独的 Brunch.io AngularJS 应用程序。由于我的前端在 http://localhost:3333 上运行和我的 Phoenix 后端 http://localhost:4000尝试 POST 到 http://localhost:4000/api/users/register 时出现此错误
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3333' is therefore not allowed access. The response had HTTP status code 404.
scope "/api", MyApp do
pipe_through :api
# Users
post "/users/register", UserController, :register
end
defmodule MyApp.UserController do
use MyApp.Web, :controller
def register(conn, params) do
IO.puts(inspect(params))
conn
|> put_status(201)
|> json %{ok: true, data: params}
end
end
最佳答案
您有几个选项可以为您连接 cors:
https://hex.pm/packages?search=cors&sort=downloads
关于angularjs - 在 Phoenix/Elixir 中启用跨域资源共享 CORS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33555753/
我有兴趣了解 AWS 物理服务器的硬件资源(CPU、磁盘、网络等)在不同应用程序之间共享的方式。人们是否有过在 AWS 上运行的服务发生莫名其妙的性能变化的经历,而您已成功将其归因于共享物理资源的另一
假设我们有 3 个人,Alice、Bob 和 Charlie。 假设他们每个人都有一种资源,Aplles、Bannanas 和 Coconuts。 他们每个人都有 3 个这种资源。 该算法的目标是进行
我是一名优秀的程序员,十分优秀!