From 3f41a26afdf95498790390dd9f34655c46f72388 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Sun, 28 May 2023 10:54:32 -0600 Subject: Añade dominio de app en políticas cors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/cards_controller.rb | 10 ++++++++++ config/initializers/cors.rb | 2 +- config/routes.rb | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/cards_controller.rb b/app/controllers/api/cards_controller.rb index f9f977b..58110c6 100644 --- a/app/controllers/api/cards_controller.rb +++ b/app/controllers/api/cards_controller.rb @@ -9,6 +9,16 @@ module Api render json: serialized_collection.serializable_hash, status: :ok end + + def show + @card = current_user_account.cards.find_by(id: params[:id]) + + if @card + render json: serialized_object.serializable_hash, status: :ok + else + render status: :not_found + end + end def create @card = current_user_account.cards.new(permitted_params) diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index c4ce61e..7e42e36 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -8,7 +8,7 @@ Rails.application.config.middleware.insert_before 0, Rack::Cors do allow do - origins 'localhost:5173', '127.0.0.1:5173', 'silosneeded.com', 'pia.silosneeded.com' + origins 'localhost:5173', '127.0.0.1:5173', 'silosneeded.com', 'https://pia.silosneeded.com' resource '*', headers: :any, methods: %i[get post put patch delete options head] end diff --git a/config/routes.rb b/config/routes.rb index b5289c8..633b56d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,6 +18,7 @@ Rails.application.routes.draw do post '/account/cart', to: 'carts#create' delete '/account/cart/:id', to: 'carts#destroy' get '/account/cards', to: 'cards#index' + get '/account/cards/:id', to: 'cards#show' post '/account/cards', to: 'cards#create' put '/account/cards/:id', to: 'cards#update' delete '/account/cards/:id', to: 'cards#destroy' -- cgit v1.2.3