Skip to content

Update web.rb to allow external device access and update README #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ This is a simple [Sinatra](http://www.sinatrarb.com/) webapp that you can use to
ℹ️ You also need to obtain your Stripe **secret, test mode** API Key, available in the [Dashboard](https://dashboard.stripe.com/account/apikeys). Note that you must use your secret key, not your publishable key, to set up the backend. For more information on the differences between **secret** and publishable keys, see [API Keys](https://stripe.com/docs/keys). For more information on **test mode**, see [Test and live modes](https://stripe.com/docs/keys#test-live-modes).

## Running the app
If you are testing this application on a device other than `localhost` (such as a mobile phone or a Stripe card reader), you need to modify the Sinatra configuration to bind the server to all available IP addresses. By default, Sinatra only binds to `localhost`, which means that only your computer can access the app.

### Steps to Modify the Configuration:
1. Open the `web.rb` file in the project.
2. Add or modify the following line to bind the server to `0.0.0.0`, allowing external devices to connect:

```ruby
configure do
set :bind, '0.0.0.0' # Bind to all available network interfaces
end

### Running on Render

Expand Down
3 changes: 2 additions & 1 deletion web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
# https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
# This enables the requires CORS headers to allow the browser to make the requests from the JS Example App.
configure do
enable :cross_origin
set :bind, '0.0.0.0' # Bind to all available network interfaces (important for testing with external devices)
enable :cross_origin # Already present in your code
end

before do
Expand Down