R
Railway•13mo ago
Yomyam

Caddyfile root path not render

How to solve this? (/admin/users/ works fine)
:{$PORT} {
log {
format console
}

reverse_proxy {$FRONTEND_HOST}

handle_path /api/* {
reverse_proxy {$BACKEND_HOST}
}

handle_path /admin/* {
reverse_proxy {$ADMIN_HOST}
}
}
:{$PORT} {
log {
format console
}

reverse_proxy {$FRONTEND_HOST}

handle_path /api/* {
reverse_proxy {$BACKEND_HOST}
}

handle_path /admin/* {
reverse_proxy {$ADMIN_HOST}
}
}
Solution:
redir /admin /admin/ permanent
redir /admin /admin/ permanent
...
Jump to solution
25 Replies
Percy
Percy•13mo ago
Project ID: N/A
Brody
Brody•13mo ago
link to the proxy's domain please
Yomyam
YomyamOP•13mo ago
oh maybe i forgot to set base url in project (skill issues coolcry )
No description
Brody
Brody•13mo ago
the caddyfile you sent, is that your entire caddyfile?
Yomyam
YomyamOP•13mo ago
no actually it's
{ # global options
admin off # theres no need for the admin api in railway's environment
persist_config off # storage isn't persistent anyway
auto_https off # railway handles https for us, this would cause issues if left enabled
log { # runtime logs
format console # set runtime log format to console mode
}
servers { # server options
trusted_proxies static private_ranges # trust railway's proxy
}
}

:{$PORT} {
log {
format console
}

reverse_proxy {$FRONTEND_HOST}

handle_path /api/* {
reverse_proxy {$BACKEND_HOST}
}

handle_path /admin/* {
reverse_proxy {$ADMIN_HOST}
}
}
{ # global options
admin off # theres no need for the admin api in railway's environment
persist_config off # storage isn't persistent anyway
auto_https off # railway handles https for us, this would cause issues if left enabled
log { # runtime logs
format console # set runtime log format to console mode
}
servers { # server options
trusted_proxies static private_ranges # trust railway's proxy
}
}

:{$PORT} {
log {
format console
}

reverse_proxy {$FRONTEND_HOST}

handle_path /api/* {
reverse_proxy {$BACKEND_HOST}
}

handle_path /admin/* {
reverse_proxy {$ADMIN_HOST}
}
}
nvm i think it's render only /admin/ but not work for /admin do i need to make it handle /admin too?
Brody
Brody•13mo ago
/admin would count as a frontend path, and you should leave it that way you can setup a redirect if you absolutely think it's necessary
Yomyam
YomyamOP•13mo ago
alright, i'll try that
Brody
Brody•13mo ago
keyword, if it's absolutely necessary
Yomyam
YomyamOP•13mo ago
hmm can you give me some example? it's slightly necessary because i separate backoffice project and storefront project and backoffice has same problem too
Brody
Brody•13mo ago
you already said you can access it from /admin/ so i dont see the issue?
Yomyam
YomyamOP•13mo ago
yeah but /admin without / at end of path is not work
Brody
Brody•13mo ago
right but why does that matter?
Yomyam
YomyamOP•13mo ago
im afraid that my team will confuse abit why they can't access admin route (so they don't know that need to add / in the end of path)
Brody
Brody•13mo ago
tell them 🤣😆
Yomyam
YomyamOP•13mo ago
yeah ill try but it's would be great if I can make it work Sad
Brody
Brody•13mo ago
then do the redirect
Yomyam
YomyamOP•13mo ago
with caddy?
Brody
Brody•13mo ago
yes
Solution
Brody
Brody•13mo ago
redir /admin /admin/ permanent
redir /admin /admin/ permanent
Yomyam
YomyamOP•13mo ago
don't have any alternative way to solve this right? just personal curious, maybe i'll need to use alternative way in the future
Brody
Brody•13mo ago
whats wrong with the redirect
Yomyam
YomyamOP•13mo ago
nah it's work great but i just curious 19dollarinsanity
Brody
Brody•13mo ago
the redirect would be the best method, you cant match to /admin* since that would also match /admin123445 and you can see how that wouldn't be ideal
Yomyam
YomyamOP•13mo ago
alright i see i have no question now tysm! heart
Brody
Brody•13mo ago
no problem!
Want results from more Discord servers?
Add your server