Skip to content

Scaffold generated code gives a CSRF error on delete #339

Description

@satb

Description

Very new to Crystal and Amber. Was going through the guides and generated a basic project with one User model. The app started and everything was good but "delete" of the user isn't working. It fails with a "CSRF check failed." error upon delete.

Also delete musn't be a http get request but a http post. The network request on delete is a GET with out of the box scaffolding and the URL looks like this - "http://localhost:3000/users/1?_method=delete"

Steps to Reproduce

  1. amber new myapp
  2. amber g scaffold User first_name:string last_name:string
  3. shards install (took me a while to figure out why amber was complaining that "require "amber"" is failing. Looks like crystal shards now install to a local lib folder
  4. amber w
  5. open http://localhost:3000
  6. Create a new user and try to delete the user

Expected behavior: http post request with _method of delete and no CSRF error

Actual behavior: http get request with an error that says "CSRF check failed."

Reproduces how often: Everytime

Versions

❯ amber --version
Amber CMD (amberframework.org) - v0.3.0

Additional Information

Just an out of the box scaffolding

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions