Am I missing something?
# ask-questions
w
Am I missing something?
s
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
UI is working fine, but when i access example.com/backend it says error 401 authorization token not found.
s
It sounds like
/backend
is pointing to
/api
which it shouldn't be - it should point to
/
on port :3100
w
Yes I have done the same thing. But getting the same error
s
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
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
I see, I think
/backend
is being passed along to the backend by ingress/loadbalancer.
w
yess the same exact error
s
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
I know subdomains are the solution, but I wanted to try every possible solution before coming to that.
s
Ok. The other solution is to replace the path in ingress before passing the request to the backend
w
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
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
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
If you take the rewrite approach then example.com/backend should work (since it will be routed to api:3100)
w
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
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
but frontend is already running on example.com
s
It's not hosting the api on example.com. It's modifying the request payload sent to the API
w
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
yes
w
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
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
yeah i will go with that, thank you for your help man @swift-helmet-3648