Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add development reverse proxy #39

Merged
merged 10 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ services:
source: ../app
target: /app

caddy:
image: caddy
volumes:
- "../caddy/Caddyfile.dev:/etc/caddy/Caddyfile"
ports:
- "3000:3000"
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved

volumes:
# Persist strapi database
strapi-data:
12 changes: 12 additions & 0 deletions Caddyfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
auto_https off
}

http://localhost:3000 {
reverse_proxy /api* http://strapi:8001
reverse_proxy /admin* http://strapi:8001
reverse_proxy /i18n* http://strapi:8001
reverse_proxy /content-manager* http://strapi:8001

reverse_proxy http://app:3000
}
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 10 additions & 9 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions caddy/Caddyfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
auto_https off
}

http://localhost:3000 {
handle_path /strapi* {
reverse_proxy http://strapi:8001
}

reverse_proxy http://app:3000
}
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions strapi/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
HOST=0.0.0.0
PORT=8001
URL=http://localhost:3000/strapi
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved
APP_KEYS="toBeModified1,toBeModified2"
API_TOKEN_SALT=tobemodified
ADMIN_JWT_SECRET=tobemodified
Expand Down
1 change: 1 addition & 0 deletions strapi/config/middlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export default [
"strapi::session",
"strapi::favicon",
"strapi::public",
{ resolve: "./src/middlewares/admin-redirect" },
];
1 change: 1 addition & 0 deletions strapi/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export default ({ env }) => ({
app: {
keys: env.array("APP_KEYS"),
},
url: env("URL", "http://localhost:3000/strapi"),
});
15 changes: 15 additions & 0 deletions strapi/src/middlewares/admin-redirect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* `admin-redirect` middleware
*/
import { Strapi } from "@strapi/strapi";

export default (config, { strapi }: { strapi: Strapi }) => {
const redirects = ["/", "/index.html"].map((path) => ({
method: "GET",
path,
handler: (ctx) => ctx.redirect(strapi.config.admin.url),
config: { auth: false },
}));

strapi.server.routes(redirects);
};