Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grape-cors

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grape-cors

  • 0.9.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

grape-cors

Ruby Grape Api extension with Cross-origin resource sharing

Example:


  class API < Grape::API

    get :info do
      #> some logic here
    end

  end

  Grape::CORS.apply!
  #> and ready to use!

In case if you need to use the 'options' call, you should use by hand the following method:

  • init_cors_headers! because the apply method will not override the options enpoints (safety reasons) And otherwise, that option call will lack the required headers

if you want change any of the cors object, you can do so in the following way:


  #> Defaults
  Grape::CORS::Config.headers  #> [ 'Content-Type' ]
  Grape::CORS::Config.origin   #> [ '*' ]
  Grape::CORS::Config.methods  #> [ 'HEAD', 'OPTIONS', 'GET', 'POST', 'PUT', 'DELETE' ]

  Grape::CORS::Config.acah     #> 'Access-Control-Allow-Headers'
  Grape::CORS::Config.acao     #> 'Access-Control-Allow-Origin'
  Grape::CORS::Config.acam     #> 'Access-Control-Allow-Methods'


  Grape::CORS::Config.origin.clear
  Grape::CORS::Config.origin.push(some_origin_site)

Happy coding! :)

FAQs

Package last updated on 08 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc