From 1f83d7512c18da3ee85aa0fcc11fbb293450cac9 Mon Sep 17 00:00:00 2001 From: HaimKortovich Date: Thu, 16 Apr 2026 16:12:29 -0500 Subject: [PATCH] fix cors --- config/runtime.exs | 5 +++++ flake.nix | 4 ++-- .../consumers/solicitation_requested_consumer.ex | 7 +++---- lib/workload_service_web/endpoint.ex | 1 + mix.exs | 3 ++- mix.lock | 1 + ops/chart/values.yaml | 2 ++ 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/config/runtime.exs b/config/runtime.exs index faa5979..554dbf2 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -35,6 +35,11 @@ if amqp_url do config :workload_service, :amqp_url, amqp_url end +cors_origin = System.get_env("CORS_ORIGIN", "*") + +config :cors_plug, + origin: cors_origin + # ## Using releases # # If you use `mix release`, you need to explicitly enable the server diff --git a/flake.nix b/flake.nix index bd7b199..dc0a322 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ mixFodDeps = beamPackages.fetchMixDeps { inherit pname version; src = ./.; - sha256 = "sha256-YkX+Bti+GyU6RQOjVTwsPIWKuqJox0lz+qK2V8Zg1XI="; + sha256 = "sha256-FCkU33NQWIkQYiiOlYLsPxazR8ocHAzmbuu5Eb3vocE="; }; package = beamPackages.mixRelease { inherit pname version mixFodDeps; @@ -52,4 +52,4 @@ }; } ); -} \ No newline at end of file +} diff --git a/lib/workload_service/consumers/solicitation_requested_consumer.ex b/lib/workload_service/consumers/solicitation_requested_consumer.ex index f645d08..a395baa 100644 --- a/lib/workload_service/consumers/solicitation_requested_consumer.ex +++ b/lib/workload_service/consumers/solicitation_requested_consumer.ex @@ -115,9 +115,8 @@ defmodule WorkloadService.Consumers.SolicitationRequestedConsumer do provider_id: event["provider_id"], provider_name: event["provider_name"] || "", task_info: %{ - "quote_id" => event["quote_id"], - "plan_id" => event["plan_id"], - "document_url" => result["document_url"] + "quote" => event["quote"], + "plan" => event["plan"] }, attachments: [result["document_url"]] |> Enum.filter(& &1) } @@ -135,4 +134,4 @@ defmodule WorkloadService.Consumers.SolicitationRequestedConsumer do defp amqp_url do Application.get_env(:workload_service, :amqp_url, "amqp://guest:guest@localhost:5672") end -end \ No newline at end of file +end diff --git a/lib/workload_service_web/endpoint.ex b/lib/workload_service_web/endpoint.ex index 0e35c37..df9d0d3 100644 --- a/lib/workload_service_web/endpoint.ex +++ b/lib/workload_service_web/endpoint.ex @@ -29,5 +29,6 @@ defmodule WorkloadServiceWeb.Endpoint do plug Plug.MethodOverride plug Plug.Head plug Plug.Session, @session_options + plug CORSPlug plug WorkloadServiceWeb.Router end diff --git a/mix.exs b/mix.exs index ab040c3..6efc0a6 100644 --- a/mix.exs +++ b/mix.exs @@ -44,7 +44,8 @@ defmodule WorkloadService.MixProject do {:flop, "~> 0.20"}, {:amqp, "~> 4.1"}, {:uuid, "~> 1.1"}, - {:req, "~> 0.5"} + {:req, "~> 0.5"}, + {:cors_plug, "~> 3.0"} ] end diff --git a/mix.lock b/mix.lock index 00a73ec..40084cb 100644 --- a/mix.lock +++ b/mix.lock @@ -6,6 +6,7 @@ "commanded": {:hex, :commanded, "1.4.9", "289bc371943cf082f1161b1560563f5451ca176c967670cccd63fc3988fcd225", [:mix], [{:backoff, "~> 1.1", [hex: :backoff, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.2", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "a4f49c23041a23687aa10e99f3db7ee3b8ae470bb615b73b9f887b86437263e7"}, "commanded_ecto_projections": {:hex, :commanded_ecto_projections, "1.4.0", "a1b220577577d5e0aee4c92b2d9bc6de221f9c1ac2ab36932cba15881761332f", [:mix], [{:commanded, "~> 1.4", [hex: :commanded, repo: "hexpm", optional: false]}, {:ecto, "~> 3.11", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.11", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "8919a6173cd8f30fe2f948c2967f9289c7f5fe4eeca7abc67966bfca31f4aa9f"}, "commanded_eventstore_adapter": {:hex, :commanded_eventstore_adapter, "1.4.2", "4f2d9d9bd8ef7807a5a4c278b4344adddbbbb4d9c86c693872bc85b944be1fe8", [:mix], [{:commanded, "~> 1.4", [hex: :commanded, repo: "hexpm", optional: false]}, {:eventstore, "~> 1.4", [hex: :eventstore, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "26eaa68515e3e73834d769b73bddfea76c3fdcaff085d735c22b82a66ba19b10"}, + "cors_plug": {:hex, :cors_plug, "3.0.3", "7c3ac52b39624bc616db2e937c282f3f623f25f8d550068b6710e58d04a0e330", [:mix], [{:plug, "~> 1.13", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "3f2d759e8c272ed3835fab2ef11b46bddab8c1ab9528167bd463b6452edf830d"}, "credentials_obfuscation": {:hex, :credentials_obfuscation, "3.5.0", "61e282adfb4439486b3994faaec69543c7ee6cc7e70c6340e8853fd9deaf8219", [:rebar3], [], "hexpm", "843adbe3246861ce0f1a0fa3222f384834eb31defd8d6b9cba7afd2977c957bc"}, "db_connection": {:hex, :db_connection, "2.9.0", "a6a97c5c958a2d7091a58a9be40caf41ab496b0701d21e1d1abff3fa27a7f371", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "17d502eacaf61829db98facf6f20808ed33da6ccf495354a41e64fe42f9c509c"}, "decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"}, diff --git a/ops/chart/values.yaml b/ops/chart/values.yaml index b80cbc5..3edcb27 100644 --- a/ops/chart/values.yaml +++ b/ops/chart/values.yaml @@ -39,6 +39,8 @@ controllers: LOG_LEVEL: debug MIX_ENV: prod PORT: "8080" + CORS_ORIGIN: + value: "*" PHX_HOST: "0.0.0.0" PHX_SERVER: "true" RABBITMQ_HOST: