create-apollo-monorepo 0.5.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +65 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -409,6 +409,58 @@ function writePnpmWorkspace(targetDir) {
|
|
|
409
409
|
);
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
+
// Single-origin nginx reference. Only emitted when adminPrefix is set, since
|
|
413
|
+
// in separate-origins mode the two apps live on their own domains/ports and
|
|
414
|
+
// don't need the prefix-aware location ordering.
|
|
415
|
+
function writeNginxSample(targetDir, adminPrefix) {
|
|
416
|
+
const prefix = adminPrefix || "/admin";
|
|
417
|
+
const conf = `# Apollo CMS — single-origin nginx sample.
|
|
418
|
+
# Mirrors apps/frontend/next.config.ts rewrites (frontend :3001 / backend :3000).
|
|
419
|
+
# No caching headers — Next.js sets its own. Add SSL + HTTP→HTTPS in production.
|
|
420
|
+
|
|
421
|
+
upstream apollo_frontend { server 127.0.0.1:3001; }
|
|
422
|
+
upstream apollo_backend { server 127.0.0.1:3000; }
|
|
423
|
+
|
|
424
|
+
server {
|
|
425
|
+
listen 80;
|
|
426
|
+
server_name _;
|
|
427
|
+
|
|
428
|
+
client_max_body_size 50m;
|
|
429
|
+
|
|
430
|
+
proxy_http_version 1.1;
|
|
431
|
+
proxy_set_header Host $host;
|
|
432
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
433
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
434
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
435
|
+
proxy_set_header X-Forwarded-Host $host;
|
|
436
|
+
|
|
437
|
+
# Backend — admin UI + chunks (APOLLO_ASSET_PREFIX=${prefix}), media, Sentry tunnel
|
|
438
|
+
location = ${prefix} { proxy_pass http://apollo_backend; }
|
|
439
|
+
location ^~ ${prefix}/ { proxy_pass http://apollo_backend; }
|
|
440
|
+
location ^~ /uploads/ { proxy_pass http://apollo_backend; }
|
|
441
|
+
location = /monitoring { proxy_pass http://apollo_backend; }
|
|
442
|
+
|
|
443
|
+
# Backend SSE — long-lived, no buffering
|
|
444
|
+
location ^~ /api/editing-presence/ {
|
|
445
|
+
proxy_pass http://apollo_backend;
|
|
446
|
+
proxy_buffering off;
|
|
447
|
+
proxy_read_timeout 24h;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
# Backend APIs (mirror the list in apps/frontend/next.config.ts).
|
|
451
|
+
# \`editing-presence\` is included so the bare path also routes to backend;
|
|
452
|
+
# streaming sub-paths still match the \`^~\` block above first.
|
|
453
|
+
location ~ ^/api/(auth|v1|cron|email|health|mcp|admin|editing-presence)(/|$) {
|
|
454
|
+
proxy_pass http://apollo_backend;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
# Frontend — everything else
|
|
458
|
+
location / { proxy_pass http://apollo_frontend; }
|
|
459
|
+
}
|
|
460
|
+
`;
|
|
461
|
+
writeFileSync(resolve(targetDir, "nginx.conf.sample"), conf);
|
|
462
|
+
}
|
|
463
|
+
|
|
412
464
|
function writeRootGitignore(targetDir) {
|
|
413
465
|
const ignore = [
|
|
414
466
|
"node_modules",
|
|
@@ -857,6 +909,13 @@ paths to the backend so /_next/* doesn't collide:
|
|
|
857
909
|
The frontend MUST NOT define routes at \`/admin\`, \`/api/auth\`, \`/api/v1\`, etc.
|
|
858
910
|
If you need your own API, namespace it under \`/api/internal/*\` or similar.
|
|
859
911
|
|
|
912
|
+
### Reverse proxy (nginx)
|
|
913
|
+
|
|
914
|
+
A reference \`nginx.conf.sample\` ships at the repo root with the same routing
|
|
915
|
+
baked in (frontend on :3001, backend on :3000). Use it when fronting both apps
|
|
916
|
+
behind a single TLS-terminating proxy outside Vercel — drop in your domain and
|
|
917
|
+
SSL certs.
|
|
918
|
+
|
|
860
919
|
To **disable** single-origin and run the backend on its own subdomain,
|
|
861
920
|
delete \`APOLLO_ASSET_PREFIX\` from \`apps/backend/.env.local\` and remove the
|
|
862
921
|
\`rewrites()\` block from \`apps/frontend/next.config.ts\`.
|
|
@@ -1072,7 +1131,12 @@ async function main() {
|
|
|
1072
1131
|
writeRootGitignore(targetDir);
|
|
1073
1132
|
writeRootEnv(targetDir, { dbUrl, siteUrl, locale, authSecret, cronSecret, adminPrefix, backendInternalUrl });
|
|
1074
1133
|
writeReadme(targetDir, dirName, frontendName, adminPrefix);
|
|
1075
|
-
|
|
1134
|
+
if (adminPrefix) writeNginxSample(targetDir, adminPrefix);
|
|
1135
|
+
success(
|
|
1136
|
+
`package.json, pnpm-workspace.yaml, .gitignore, .env.local, README.md${
|
|
1137
|
+
adminPrefix ? ", nginx.conf.sample" : ""
|
|
1138
|
+
}`,
|
|
1139
|
+
);
|
|
1076
1140
|
|
|
1077
1141
|
// ── Step 4: git init ──
|
|
1078
1142
|
step(4, "Initializing git");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-apollo-monorepo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Scaffold a monorepo with a frontend app and Apollo CMS as a git submodule backend (single-origin via Next.js rewrites + assetPrefix)",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-apollo-monorepo": "index.mjs"
|