https://github.com/raphox/next-rails-app
A Rails app using https://github.com/raphox/next-rails
https://github.com/raphox/next-rails-app
Last synced: about 1 year ago
JSON representation
A Rails app using https://github.com/raphox/next-rails
- Host: GitHub
- URL: https://github.com/raphox/next-rails-app
- Owner: raphox
- Created: 2023-11-16T21:07:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-02T02:11:32.000Z (over 1 year ago)
- Last Synced: 2025-02-02T03:19:31.774Z (over 1 year ago)
- Language: Ruby
- Size: 464 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gem [next_rails_scaffold](https://github.com/raphox/next_rails_scaffold) sample app
## Setup
Create the Rails app:
```
rails new my_api --api
```
Install dependencies:
```
# Uncomment the `gem "rack-cors"` line in the Gemfile.
bundle add foreman --group "development"
bundle add next_rails_scaffold
```
Allow to local environment to access the Rails app from any resource.:
```ruby
# config/initializers/cors.rb
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins Rails.env.local? ? "*" : "example.com" # Change `example.com` as you need.
resource "*",
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
end
```
Create your `Procfile.local`:
```
# Procfile.local
api: bundle exec rails server -p $PORT -b 0.0.0.0
next: cd ./frontend && NEXT_PUBLIC_API_URL=http://0.0.0.0:$(( PORT - 100 ))/api yarn dev -p $PORT -H 0.0.0.0
```
## Running
After to [setup](#setup), run to following command to start the Rails and Next.js applications:
```
foreman start -f Procfile.local --port=8000
```
> **TIP:** Use `foreman start -f Procfile.github --port=8000` on Github.