G
G
gsaw2022-02-02 21:07:47
React
gsaw, 2022-02-02 21:07:47

Why does basePath work so weird in next.js?

I'm confused about how to deploy next.js app in kubernetes cluster. It runs in a container, listening on port 8100 inside the container. A config has been created in ingres, which redirects requests along the path /app/v1/vamos-client to this service with the application.

If I access the application via an external URL, I get the first page, and all assets from _next are not loaded with 404.

If I add assetPrefix: '/app/v1/vamos-client' to next.config.js, then all assets loaded, but all links without the prefix '/app/v1/vamos-client'

If I add basePath: '/app/v1/vamos-client' to the next.config.js config, then the assets stop loading again.

I just don't understand what he wants. Why doesn't he want to work with basePath. Moreover, if I locally assemble the container and run it simply in the docker, then the application works with any combination of basePath and assetPrefix.

maybe there is some old ingress that rewrites the urls? The cluster is in the cloud, I don't have direct access to it. I just commit the code on the github, and he collects and deploys it himself. Just tired already.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gsaw, 2022-02-06
@gsaw

It was in the ingress controller and a crooked config. I tested with ingress-nginx, and there was traefik on the server. And the PrefixStrip was set in the config, that is, the /app/v1/vamos-client backend did not reach, it received only /
Removed this Strip and everything worked as expected.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question