1. The problem I’m having:
I am trying to forward my user auth ID to a HTTP header so that my backend server can use it.
Here is the section of my Caddyfile in question:
:80
root * /home/myuser/website
file_server
handle_path /app* {
basic_auth {
user password
}
header X-User-ID "{http.auth.user.id}"
root * /home/myuser/website
file_server {
index file.html
}
}
Note: ive left out some other handle paths
I have also tried removing the quotes around {http.auth.user.id}
I have also tried adding the following line after asking chatGPT for help
header Access-Control-Expose-Headers "X-User-ID"
2. I am using some JS code client side to retrieve and log the header from the server, this is the response:
X-User-ID:"{http.auth.user.id}"
I also used curl -I and got the same result.
3. Caddy version:
v2.8.4
4. How I installed and ran Caddy:
I installed caddy with apt and I am running caddy with caddy run
a. System environment:
I am running on Ubuntu 22.04 on a raspberry pi
Sorry for the wait, I had a busy week.
Looks like you already got your answer here though:
Basically it’s a directive ordering issue.
1 Like
system
(system)
Closed
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.