Whenever I try to access Forest Admin it shows me this screenshot:
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.
Ability to view data
There are no errors the logs on the Rails side.
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
- Database type: postgresql
- Recent changes made on your end if any: …
Thanks for reaching out
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 am coming back to an old account and project, that now has a new repo and a fresh install of forest_liana.
However, I did also try setting up a new project from scratch, and the same thing is happening there.
Some interesting behaviour: it does load the schema and database fields somehow, but not the actual data.
Some more information:
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.
So the data requests are not even getting to the router before they are rejected with 401.
Thanks for your answer.
So that we can help you out, could you please:
- share the logs you’re having when starting your agent?
- share the logs you’re having in your browser as well (which call in failing)?
- tell me if you well have this line
mount ForestLiana::Engine => '/forest' in your
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.
Thanks for the help in the meantime!
@chrisingram thanks for sharing this!
Hope you’re fully up and running now.