github / github/codespaces-rails
AuthenticityToken Missmatch on CRUD after Port Forwarding
- Vorherrschende Sprache
- Ruby
- Sterne
- 148
- Forks
- 121
- Ø Merge
- 4 T. 12 Std.
- Gemergte PRs (30 T.)
- 2
Beschreibung
I am encountering forgery protection issue when I try to do regular CRUD operations that connected to postgres like normal, so everytime I did POST action, the console throws message below:
```
ActionController::InvalidAuthenticityToken (HTTP Origin header (http://localhost:3000) didn't match request.base_url (https://{space-name}-{space-id}-3000.app.github.dev)
```
So far, [this answer (22965)](https://github.com/rails/rails/issues/22965#issuecomment-172983268) can solve the problem, which suggest to add:
```ruby
config.action_controller.forgery_protection_origin_check = false
```
to _development.rb_, or put
```ruby
skip_forgery_protection
```
on _application_controller.rb_
I still feel uncomfortable with this approach since I can't do the rails standards, I've been doing this just fine in another IDE like **Gitpod** or **AWS Cloud9**, but it's just different here. I'm trying figuring out on the VM level try to modify nginx config until I realize that codespaces service might run inside a container LOL. I still think that this because I'm not sure how port forwarding works in this service, but if that's the reason, why I can still access the app only with GET requests?
Some help/ guidance from official team would be nice!
cc @joshaber @samruddhikhandale @bdmac
Beitragsleitfaden
Rechercherichtung
Beginnen Sie damit, den POST-Fehler in der per Port-Forwarding weitergeleiteten Codespaces-App zu reproduzieren, und untersuchen Sie die im Bericht erwähnten Optionen in development.rb und application_controller.rb. Vergleichen Sie den Origin der weitergeleiteten Anfrage mit request.base_url und prüfen Sie die nginx- oder Container-Konfiguration für das Port-Forwarding; als abgeschlossen gilt die Aufgabe, wenn die Konfigurationsabweichung identifiziert und eine standardkonforme Lösung dokumentiert wurde, ohne den Fälschungsschutz zu deaktivieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- rails, ruby
- Bereich
- backend, infrastructure, security
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 30/100