diff --git a/README.md b/README.md index 4ea46e0dd..89f67e9cf 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,15 @@ cd DoenetTools npm install ``` -**3. Create the `.env` file** +**3. Create the API `.env` file** ```bash npm run setup ``` -This copies `apps/api/.env.example` to `apps/api/.env`. The defaults work for local development, but edit as needed (e.g. change `DATABASE_HOST`, `DATABASE_PORT`, or `DATABASE_PASSWORD` if your MySQL setup differs — and update `DATABASE_URL` to match). +This copies `apps/api/.env.example` to `apps/api/.env`. + +The API defaults work for local development, but edit as needed (e.g. change `DATABASE_HOST`, `DATABASE_PORT`, or `DATABASE_PASSWORD` if your MySQL setup differs — and update `DATABASE_URL` to match). The web defaults are already committed in `apps/web/.env`; use `apps/web/.env.local` for machine-specific overrides. **4. Start the database** @@ -68,12 +70,17 @@ This starts: - Shared package watcher - Express API → http://localhost:3000 -- React SPA → http://localhost:8000 (proxies `/api/*` to the API) +- React SPA → http://localhost:8000 (proxies `/api/*` to the API and `/blog/*` to Astro) - Astro site → http://localhost:4321 This command first builds `shared` once, then starts its watch process alongside the app, API, and web dev servers. +For local development, use the app origin for both frontends: + +- app pages → `http://localhost:8000/...` +- blog pages → `http://localhost:8000/blog/...` + Alternatively, run each in a separate terminal if needed: ```bash diff --git a/apps/app/vite.config.mts b/apps/app/vite.config.mts index fcfa0e06c..c431c5e7e 100644 --- a/apps/app/vite.config.mts +++ b/apps/app/vite.config.mts @@ -36,6 +36,11 @@ export default defineConfig({ server: { port: 8000, proxy: { + // Route blog pages and Astro-generated assets through the same frontend + // entry point used by the app in production. + "/blog": "http://localhost:4321", + "/_astro": "http://localhost:4321", + "/_image": "http://localhost:4321", "/cyapi": "http://apache", //"/media": "http://apache", "/api": "http://localhost:3000", diff --git a/apps/web/.env b/apps/web/.env index 3b7170051..2d8002e0f 100644 --- a/apps/web/.env +++ b/apps/web/.env @@ -1,4 +1,13 @@ # Default local build environment variables for the Doenet blog. # This file is intentionally committed — all PUBLIC_ vars are public. -PUBLIC_DOENET_MAIN_URL=http://localhost:8000 + +# Environment-specific build values live in .env.dev3 and .env.prod. +# Use .env.local for machine-specific overrides. +# Use `npm run build -- --mode dev3` or `npm run build -- --mode prod` to +# select a non-default env file. + +# Main Doenet application URL +PUBLIC_APP_URL=http://localhost:8000 + +# Canonical site URL used at build time for metadata and sitemap generation PUBLIC_SITE_URL=http://localhost:4321 diff --git a/apps/web/.env.dev3 b/apps/web/.env.dev3 index a2c509901..552c0d96c 100644 --- a/apps/web/.env.dev3 +++ b/apps/web/.env.dev3 @@ -1,4 +1,4 @@ # Development environment variables for the Doenet blog. # This file is intentionally committed — all PUBLIC_ vars are public. -PUBLIC_DOENET_MAIN_URL=https://dev3.doenet.org +PUBLIC_APP_URL=https://dev3.doenet.org PUBLIC_SITE_URL=https://dev3.doenet.org diff --git a/apps/web/.env.example b/apps/web/.env.example deleted file mode 100644 index 02590194f..000000000 --- a/apps/web/.env.example +++ /dev/null @@ -1,19 +0,0 @@ -# General Environment Variables Sample -# This file shows all available environment variables for the Doenet blog -# Default local build values live in .env. -# Environment-specific build values live in .env.dev3 and .env.prod. -# Use .env.local for machine-specific overrides. -# Use `npm run build -- --mode dev3` or `npm run build -- --mode prod` to -# select a non-default env file. - -# Main Doenet application URL -# Local development: http://localhost:8000 -# Dev3: https://dev3.doenet.org -# Production: https://beta.doenet.org -PUBLIC_DOENET_MAIN_URL=https://beta.doenet.org - -# Canonical site URL used at build time for metadata and sitemap generation -# Local development: http://localhost:4321 -# Dev3: https://dev3.doenet.org -# Production: https://beta.doenet.org -PUBLIC_SITE_URL=https://beta.doenet.org diff --git a/apps/web/.env.prod b/apps/web/.env.prod index a542725d0..9bc6c6a11 100644 --- a/apps/web/.env.prod +++ b/apps/web/.env.prod @@ -1,4 +1,4 @@ # Production environment variables for the Doenet blog. # This file is intentionally committed — all PUBLIC_ vars are public. -PUBLIC_DOENET_MAIN_URL=https://beta.doenet.org +PUBLIC_APP_URL=https://beta.doenet.org PUBLIC_SITE_URL=https://beta.doenet.org diff --git a/apps/web/README.md b/apps/web/README.md index f9c917420..cafd19d42 100644 --- a/apps/web/README.md +++ b/apps/web/README.md @@ -70,7 +70,7 @@ Build commands: Public env vars: -- `PUBLIC_DOENET_MAIN_URL`: URL for the main Doenet site. If not specified, the header shows a plain image. +- `PUBLIC_APP_URL`: URL for the main Doenet app. If not specified, the header shows a plain image. - `PUBLIC_SITE_URL`: canonical site URL used for build-time metadata and sitemap generation. ## 👀 Want to learn more? diff --git a/apps/web/astro.config.mjs b/apps/web/astro.config.mjs index e1164178d..98ace2571 100644 --- a/apps/web/astro.config.mjs +++ b/apps/web/astro.config.mjs @@ -16,6 +16,9 @@ const env = loadEnv(mode, process.cwd(), ""); // https://astro.build/config export default defineConfig({ + devToolbar: { + enabled: false, + }, site: env.PUBLIC_SITE_URL, integrations: [mdx(), sitemap(), react()], markdown: { diff --git a/apps/web/src/components/Header.astro b/apps/web/src/components/Header.astro index cbdbd86a8..86b3703a9 100644 --- a/apps/web/src/components/Header.astro +++ b/apps/web/src/components/Header.astro @@ -1,6 +1,6 @@ --- import { getImage } from "astro:assets"; -import { BLOG_BASE_URL, DOENET_MAIN_URL } from "../consts"; +import { APP_URL, BLOG_BASE_URL } from "../consts"; import HeaderLink from "./HeaderLink.astro"; import doenetLogo from "../../public/Doenet_Logo_Frontpage_color_text.png"; @@ -11,8 +11,8 @@ const optimizedLogo = await getImage({ src: doenetLogo });