rack-cors | Rack Middleware for handling Cross | Runtime Evironment library
kandi X-RAY | rack-cors Summary
kandi X-RAY | rack-cors Summary
Rack::Cors provides support for Cross-Origin Resource Sharing (CORS) for Rack compatible web applications. The CORS spec allows web applications to make cross domain AJAX calls without using workarounds such as JSONP. See Cross-domain Ajax with Cross-Origin Resource Sharing.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rack-cors
rack-cors Key Features
rack-cors Examples and Code Snippets
Community Discussions
Trending Discussions on rack-cors
QUESTION
I recently upgraded from Rails 6.1.4.6 to 7.0.2.2. With this upgrade I switched from webpacker to import maps with sprockets. My repo didn't include turbolinks or stimulus and I didn't feel like adding them now either. So I re-added UJS and most of my tests pass except the action cable feature tests. It seems I cannot get action cable to connect.
Any help would be appreciated!
Gemfile
...ANSWER
Answered 2022-Mar-09 at 22:08Figured out the problem was because I had two applications.js
files. One in app/assets/javascripts/
and another in app/javascript
. Sprockets was serving my asset version of application.js due to my manifest pointing there. I adjusted the manifest and deleted the secondary application.js and all is working.
QUESTION
Good morning people.
I'm trying to understand the error below but as I'm new to rails, I didn't quite understand. Does anyone have a light on what it could be?
I searched the internet but didn't find anything specific.
I searched on the internet but didn't identify anything, if anyone has seen it or has the link, you can send me and I'll see.
If you need any more information to help, let me know and I'll edit the post and add it, I don't know if there's anything else I could have already posted.
thank you for your help !!
...ANSWER
Answered 2022-Jan-21 at 13:34First of all, the message about DidYouMean
is a deprecation warning not an error, it doesn't break your app. It means that usage of DidYouMean::SPELL_CHECKERS
is deprecated and will be removed in a future version of ruby. In this case in Ruby 3.3. You shouldn't worry about it until you use versions that are lower than 3.3.
It's not your code that triggers the warning. It comes from a gem named Thor. The issue was solved in thor version 1.2.0. You can update the gem by calling bundle update thor
.
The actual error comes from the bootsnap
gem:
QUESTION
I have a rails API serving mywebsite.com and app.mywebsite.com with rack-cors configured to allow me to make requests from both. The API sits at api.mywebsite.com.
If I make a call to an endpoint from mywebsite.com everything works as expected. However, if I then make the same call from app.myswebsite.com I get the error:
Access to fetch at 'https://api.mywebsite.com/api/v1/endpoint' from origin 'https://app.mywebsite.com' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://mywebsite.com' that is not equal to the supplied origin.
I have set debug in rack-cors and can see the correct Access-Control-Allow-Origin is sending the correct header, it just doesn't seem to make it to the browser.
I've found if I clear my cache then I'm able to successfully make the call from app.mywebsite.com but then receive the error from mywebsite.com:
Access to fetch at 'https://api.mywebsite.com/api/v1/endpoint' from origin 'https://mywebsite.com' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://app.mywebsite.com' that is not equal to the supplied origin.
So in short, my browser seems to be caching the first 'Access-Control-Allow-Origin' header it receives.
I've read I need to set the Vary response header but I already have this set to Origin.
edit: request headers from working request (mywebsite.com)
...ANSWER
Answered 2021-Oct-25 at 11:03I finally got to the bottom of this.
Chrome will still use the cached header even if the origins differ and the Vary header is present and set to 'Origin' if the ETags still match.
To get past this either unset the ETag header or vary it based on request origin.
QUESTION
Gemfile
...ANSWER
Answered 2021-Oct-10 at 13:01Use gemsets to avoid accidentally changing ruby versions, but for now use the command:
QUESTION
I have code in rails to check CORS from list of domain in env like this
...ANSWER
Answered 2021-Aug-18 at 12:30As you can see what they use in the linked rack-cors issue is of a Regexp
class, and not a String
as in your case.
I suggest concatenating 2 environment variables:
- STRING_DOMAIN_CORS="https://example1.com, https://example2.com"
- REGEXP_DOMAIN_CORS="(.*?).example.com"
and map them accordingly:
QUESTION
does anyone know why the error
"ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/pg-1.2.3-x64-mingw32/lib/2.7/pg_ext.so"
appears while trying to install pg gem in Windows 10?
I tried running gem install pg with admin privileges in command prompt in my application folder, but it throws this error.. I also checked out site https://rubygems.org/gems/pg and there copied how to install pg via command line, and what to include in Gemfile.
Here is my gem file:
ANSWER
Answered 2021-Jun-01 at 01:05I'm assuming you've downloaded and installed PostgreSQL on your system. Use the following to point the gem to where postgres is installed. This is an example of what it'd look like on my system.
QUESTION
I have an error every time my frontend project tries to do a request to the backend. For some reason it gets blocked by CORS every time i try to do a request, i've configured CORS already and i honestly have no clue what else i have to do. I'm using the rack-cors gem and i'm hosting both the frontend and the backend in heroku.
here is my cors.rb
...ANSWER
Answered 2021-May-03 at 13:43It complains that Access-Control-Allow-Origin header value is too broad: it's set to the wildcard * which means that everyone can make a request to your server. There are two ways of solving this problem
Either set Access-Control-Allow-Origin to something like [localhost:3000] instead of the wildcard, so you client (running on localhost:3000) could request the server.
Or set withCredentials=false mode on your client side. I usually use axios and and do something like this
QUESTION
----UPDATE
I have cloned the repo in an other directory and went throw the all process again, this time though I noticed that the issue comes out only after using:
...ANSWER
Answered 2021-Apr-17 at 17:00Your error is in the last line;
/var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- listen (LoadError)
bundle install --deployment --without development test
command install only production and general gems. Does not install the development or test gems. Rails read environment variables RAILS_ENV
for the setting environment. RAILS_ENV
variable if not set rails default accept development. And bundler try to load all gems + development group gems. But bundle install --deployment --without development test
command only install production and general gems. So listen gem is not installed because listen gem in development group. RAILS_ENV=production bin/rails c
command not throw error because not try to load development gems.
QUESTION
I have a project I'm trying to use ruby 3 (previously running with 2.7.2), but couldn't accomplish it.
After updated my gemfile with the ruby version and ran bundle
, I'm receiving this error when trying to access rails c
:
ANSWER
Answered 2021-Jan-08 at 00:14You have spring
in your gemfile, usually hanging consoles and servers are related to that. The webrick
gem was removed from the standard library in Ruby 3, so that's why it needs to be included in your Gemfile.
Re-add webrick
to your Gemfile, do a bundle install, and then stop the background spring server with bin/spring stop
. Then re-run the server.
Your best bet on solving issues with spring would be to head over and read about the gem on the GitHub project page, or opening a new question here on SO.
QUESTION
I have cloned an existing project and trying to run it in my system. Since this is the first time I don't have any Gemfile.lock file in my directory. I tried running bundle install and the following errors occur:
...ANSWER
Answered 2021-Apr-10 at 18:06In your project directory, try installing rails gem install rails -v 4.1.6
and removing the version from the failing gems like (liquid_markdown
, gon
, etc..) then try running bundle update
then bundle clean --force
I think this might be an issue because all the version of these gems are locked inside your Gemfile
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
Install rack-cors
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page