kianameli / venno

0 stars 0 forks source link

CORS not working for sign in #6

Closed kianameli closed 2 years ago

kianameli commented 2 years ago

PROJECT ISSUE TICKET

Unexpected Behavior

Postman signin works but trying via React app fails with CORS error:

Expected Behavior

I would expect to be able to log in and have the user displayed on the page instead of "no user"

Reproduce the Error

1. Clone this repo's 'dev' branch.
2. Initialize the rails server and then run npm start from client
3. Click on sign in and enter username: 'test2' and password: '123456', then submit 

Documentation

Access to XMLHttpRequest at 'http://localhost3000/auth/login' from origin 'http://localhost:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Attempted Resolution

I checked config/initializers/cors.rb which was all set, made sure i had CORS gem installed, made sure to run npm i in client. No dice, i really have no idea how cors works.

1. https://medium.com/@dtkatz/3-ways-to-fix-the-cors-error-and-how-access-control-allow-origin-works-d97d55946d9
2. https://stackoverflow.com/questions/57009371/access-to-xmlhttprequest-at-from-origin-localhost3000-has-been-blocked
kianameli commented 2 years ago

...missing colon between localhost and 3000