We are building a WebApp for a school project using an Ember 2.2.3 frontend with Rails 4.2.5 and Postgres 5.7 on the back. We have ran into a problem authenticating and cannot find a relevant solution. We believe ember should be encoding our email and password into JSON for authentication, and Rails is expecting a JSON object for validate and return a token. But what is actually happening is that Ember is sending a application/x-www-form-urlencoded version of the email and password, so Rails will throw a 415 Unsupported Media Type Error. We followed this tutorial for authentication:
Is there a way in Ember to change this encoding to application/json? or could we change Rails to accept application/x-www-form-urlencoded?
Here is our current authentication request header:
POST /users/sign_in HTTP/1.1
Host: localhost:3000
Connection: keep-alive
Content-Length: 63
Accept: application/json, text/javascript
Origin: http://localhost:4200
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://localhost:4200/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Aucun commentaire:
Enregistrer un commentaire