Front-end and back-end separation cross-domain problems

I have a vue+java project. When the front-end accesses the back-end interface, I can’t access the 404. This project is normal on nginx. After migrating to caddy, there is a problem. I hope you can guide me to configure the front and rear cross sections. domain problem.Below is my existing configuration.

http://localhost:2100 {
encode zstd gzip
root * /home/dist
file_server browse
reverse_proxy /api/* http://192.168.1.6:8000 {
header_up Host {http.reverse_proxy.upstream.hostport}
header_down Access-Control-Allow-Headers *
header_down Access-Control-Allow-Origin *
}
}

Please fill out the help topic template. We can’t help unless you fill it out and provide more detailed information.

1. Caddy version (caddy version):

Caddy v2

2. How I run Caddy:

In virtual machine with Ubuntu20.04

a. System environment:

Ubuntu20.04

b. Command:

caddy adapt --config /path/Caddyfile
caddy run

c. Service/unit/compose file:

systemd

d. My complete Caddyfile or JSON config:

http://localhost:2100 {
  encode zstd gzip
  root * /home/dist
  file_server browse
  reverse_proxy /api/* http://192.168.1.6:8000 {
    header_up Host {http.reverse_proxy.upstream.hostport}
    header_down Access-Control-Allow-Headers *
    header_down Access-Control-Allow-Origin *
  }
}

3. The problem I’m having:

Always 404 when my frontend calls the backend interface

4. Error messages and/or full log output:

5. What I already tried:

6. Links to relevant resources:

What version, exactly?

Show example requests.

Show your logs.

Please completely fill out the help topic template, we can’t help unless you help us help you.

This topic was automatically closed after 30 days. New replies are no longer allowed.