In dev tools, it shows a 401 unauthorized on the request to get data. There is also a CORS error on the preflight request, even though I have implemented Rack::Cors in Rails. Before I implemented Rack::Cors as suggested by the docs, there were more CORS errors.
Expected behavior
Ability to view data
Failure Logs
There are no errors the logs on the Rails side.
Context
Using Rails 7, with forest_liana 8. I have implemented Rack::Cors as per the docs.
Project name: Basejam
Team name: …
Environment name: …
Agent (forest package) name & version: forest_liana 8.0.16
Something is unclear to me: were you able to connect before? Did you do something (upgrade your liana version, change a configuration, etc) that would trigger this connection issue?
I have added some logs to the forest_liana gem code locally, and it logs fine for the authentication controller, but this log statement at the top of ForestLiana::Router::call is not logged for the data requests.
I have narrowed this down to our authentication gem (Clerk) which has Rack middleware to intercept any request with a Bearer token and return 401 immediately if it doesn’t recognise it.
This is why the requests are not getting to the router logs before they are returned.
Took me a while to find that, as I assumed user authentication logic would be at the ApplicationController level. For anyone else landing here, it looks like you just need to add /forest/* as an excluded route in the Clerk config.