From 5c47b2aacbc16d3ef3bdb846f2e928887b6e29cf Mon Sep 17 00:00:00 2001 From: Inhji Date: Fri, 9 Jun 2023 19:06:39 +0200 Subject: [PATCH] add cors_plug --- config/prod.exs | 5 +++++ lib/chiya_web/endpoint.ex | 1 + mix.exs | 1 + 3 files changed, 7 insertions(+) diff --git a/config/prod.exs b/config/prod.exs index 5408599..0bea02d 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -17,5 +17,10 @@ config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Chiya.Finch # Do not print debug messages in production config :logger, level: :debug +config :cors_plug, + origin: ["app://obsidian.md"], + max_age: 86400, + methods: ["GET", "POST"] + # Runtime production configuration, including reading # of environment variables, is done on config/runtime.exs. diff --git a/lib/chiya_web/endpoint.ex b/lib/chiya_web/endpoint.ex index db0fe20..2d909d1 100644 --- a/lib/chiya_web/endpoint.ex +++ b/lib/chiya_web/endpoint.ex @@ -38,6 +38,7 @@ defmodule ChiyaWeb.Endpoint do plug Phoenix.Ecto.CheckRepoStatus, otp_app: :chiya end + plug CORSPlug plug Phoenix.LiveDashboard.RequestLogger, param_key: "request_logger", cookie_key: "request_logger" diff --git a/mix.exs b/mix.exs index 96e88ba..6256dc8 100644 --- a/mix.exs +++ b/mix.exs @@ -33,6 +33,7 @@ defmodule Chiya.MixProject do defp deps do [ {:bcrypt_elixir, "~> 3.0"}, + {:cors_plug, "~> 3.0"}, {:earmark, "~> 1.4"}, {:ecto_autoslug_field, "~> 3.0"}, {:ecto_sql, "~> 3.6"},