Skip to content

Commit

Permalink
Improve proxy rewrite example (nginx, haproxy)
Browse files Browse the repository at this point in the history
Make trailing slash on /api/ optional to support
both /api and /api/ requests with koa router.

strapi#156 (comment)
  • Loading branch information
mattpr authored and mattp committed Mar 2, 2021
1 parent 7a09864 commit 9eae871
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ backend default-backend
server somewebserver 127.0.0.1:8080
backend strapi-backend
http-request set-path "%[path,regsub(^/api/,/)]"
http-request set-path "%[path,regsub(^/api/?,/)]"
server local 127.0.0.1:1337
```
Expand Down Expand Up @@ -227,7 +227,7 @@ backend default-backend
server somewebserver 127.0.0.1:8080
backend strapi-api-backend
http-request set-path "%[path,regsub(^/api/,/)]"
http-request set-path "%[path,regsub(^/api/?,/)]"
server local 127.0.0.1:1337
backend strapi-dashboard-backend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ server {
# Strapi API and Admin
location /api/ {
rewrite ^/api/(.*)$ /$1 break;
rewrite ^/api/?(.*)$ /$1 break;
proxy_pass http://strapi;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host;
Expand Down Expand Up @@ -191,7 +191,7 @@ server {
# Strapi API
location /api/ {
rewrite ^/api/(.*)$ /$1 break;
rewrite ^/api/?(.*)$ /$1 break;
proxy_pass http://strapi;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host;
Expand Down

0 comments on commit 9eae871

Please sign in to comment.