https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
w

wooden-river-6675

11/28/2023, 3:37 PM
Am I missing something?
s

swift-helmet-3648

11/28/2023, 3:45 PM
Your kube manifest looks fine. What is the source of the error? Can you provide a screenshot? I don't know if you're working from the growthbook UI, or are experiencing some other issue
w

wooden-river-6675

11/28/2023, 4:01 PM
UI is working fine, but when i access example.com/backend it says error 401 authorization token not found.
s

swift-helmet-3648

11/28/2023, 4:02 PM
It sounds like
/backend
is pointing to
/api
which it shouldn't be - it should point to
/
on port :3100
w

wooden-river-6675

11/29/2023, 8:09 AM
Yes I have done the same thing. But getting the same error
s

swift-helmet-3648

11/29/2023, 3:39 PM
Can you post the 401 response?
/api
is the only endpoint we have that would return that
When you hit
/
on the API, you should get something like this:
Copy code
{
  "name": "GrowthBook API",
  "production": false,
  "api_host": "<http://localhost:3100>",
  "app_origin": "<http://localhost:3000>",
  "config_source": "db",
  "email_enabled": false,
  "build": {
    "sha": "",
    "date": ""
  }
}
w

wooden-river-6675

11/29/2023, 4:30 PM
yeah if run the backend on example.com instead of /backend i get the response u gave.
but when i run frontend on example.com and backend on example.com/backend the front is accessibl but on example.com/backend it give error which i showed
s

swift-helmet-3648

11/29/2023, 4:32 PM
I see, I think
/backend
is being passed along to the backend by ingress/loadbalancer.
w

wooden-river-6675

11/29/2023, 4:33 PM
yess the same exact error
s

swift-helmet-3648

11/29/2023, 4:34 PM
My colleague mentioned something like this might be an issue - you may have an easier time using something like
<http://api.example.com|api.example.com>
instead. Alternatively, you could configure ingress to replace the path before sending to the backend but that seems harder
w

wooden-river-6675

11/29/2023, 4:35 PM
I know subdomains are the solution, but I wanted to try every possible solution before coming to that.
s

swift-helmet-3648

11/29/2023, 4:37 PM
Ok. The other solution is to replace the path in ingress before passing the request to the backend
w

wooden-river-6675

11/29/2023, 4:38 PM
can you elaborate a little, like right now I have written the host as example.com and path /backend for backendingress. Can you explain in detail then I'll do that
s

swift-helmet-3648

11/29/2023, 4:38 PM
My expertise in kubernetes is very little, I can help with what I found on google. But this looks like the right approach: https://kubernetes.github.io/ingress-nginx/examples/rewrite/
I generally think that using subdomains is the better/easier solution if you can do that.
w

wooden-river-6675

11/29/2023, 4:43 PM
thank you i'll dig into it. One last thing how should my req to backend look like for example right now it looks like example.com/backend. But considering what you showed above in the picture it gives error on localhost:3100/ backend.
s

swift-helmet-3648

11/29/2023, 4:44 PM
If you take the rewrite approach then example.com/backend should work (since it will be routed to api:3100)
w

wooden-river-6675

11/29/2023, 4:45 PM
I'm sorry I'm a lil confused. You said the /backend is being appended. So my ingress is pointing to example.com/backend/backend? is this what you're trying to say?
s

swift-helmet-3648

11/29/2023, 4:45 PM
If you take the rewrite approach, ingress will take the request from
<http://example.com/backend|example.com/backend>
and send it to your api as
<http://example.com|example.com>
w

wooden-river-6675

11/29/2023, 4:46 PM
but frontend is already running on example.com
s

swift-helmet-3648

11/29/2023, 4:47 PM
It's not hosting the api on example.com. It's modifying the request payload sent to the API
w

wooden-river-6675

11/29/2023, 4:49 PM
so I should only rewrite and the other work is fine u mean
and for the api host in env what will be the path when I rewrite api_host= example.com/backend right? @swift-helmet-3648
s

swift-helmet-3648

11/29/2023, 4:55 PM
yes
w

wooden-river-6675

11/29/2023, 5:03 PM
i added nginx.ingress.kubernetes.io/rewrite-target: / for backend ingress but still getting same error
@swift-helmet-3648
i dont understand onething if the api is hosted on example.com/backend then how re writing it to example.com will help it access the backend
s

swift-helmet-3648

11/29/2023, 5:27 PM
I'm not 100% sure myself. I think you would need Kubernetes support at this point
Again - I would recommend subdomains, I think it's much easier.
w

wooden-river-6675

11/29/2023, 5:49 PM
yeah i will go with that, thank you for your help man @swift-helmet-3648
3 Views