March 3, 20251 yr I'm developing a Home Assistant integration for Unraid Connect and am experiencing CORS policy issues when making GraphQL requests. Environment: - Unraid Server: Running Unraid Connect plugin with API enabled - Client: Home Assistant integration making GraphQL API requests - API Key: Generated using unraid-api apikey --create Issue Details: When making GraphQL requests to http://[unraid-ip]/graphql, all requests are rejected with the exact error: "The CORS policy for this site does not allow access from the specified Origin." The API responds with HTTP 200 status code but returns this CORS error in the response body. Steps Taken: 1. Added Home Assistant URL to "Unraid API extra origins" in the Unraid Connect settings (http://homeassistant_ip:8123) 2. Clicked APPLY to save changes 3. Restarted Unraid Connect services 4. Tried with and without port number in the origin URL 5. Tried multiple API key formats (standard, with unraid_ prefix, and both local and remote keys) 6. Enabled developer mode using "unraid-api developer" 7. Verified that non-GraphQL requests to other endpoints do work properly Request Details: - Header used: {"x-api-key": "[valid API key]", "Origin": "http://192.168.1.100", "Referer": "http://192.168.1.100"} - Simple query: "query { online }" - GraphQL endpoint: http://[unraid-ip]/graphql I also noticed that requests redirect to https://192-168-1-100.xxxxxxxxxxxxxxxxxxxxxx.myunraid.net, which might be complicating the CORS situation. Basic HTTP connectivity to the Unraid server works, but the GraphQL requests are blocked due to CORS. Expected Behavior: GraphQL requests should be allowed when using a valid API key and when the client origin is in the allowed origins list, as indicated in the documentation. Please advise on the correct configuration for allowing external applications to use the GraphQL API, or consider updating the CORS handling to properly respect the configured allowed origins. Or is this just because GraphQL Sandbox is proxied through Unraid Connect cloud services and I should wait until API is included in Unraid OS and seperate from Connect plugin later in the year? Thanks for the help
March 4, 20251 yr Author @pujitm I managed to get my code to handle the URL redirects to https://xxxxxxxxx.myunraid.net It connects now to the Sandbox environment and I can run queries.
March 4, 20251 yr great to hear. does it still seem like there's an issue on the api side? btw this use case is exactly the kind of stuff we're building the api for, so anything we can do to smooth out rough edges, make things simpler, etc, just let us know. I'm also curious: what was the most frustrating/painful part of this for you?
March 4, 20251 yr Author @pujitm I think I have resolved my issue with the API for now. The Authentication and Redirect Handling was a hurdle for me: The code had to discover and handle the redirect URL. Maybe this is something worth mentioning in the Unraid API developer documentation. I'm happy to help contribute. And here's the tool to test the api. https://github.com/domalab/unraid-api-client
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.