How-To: Connect MediaPlanner Frontend to Backend
1. Clone the MediaPlanner Repos
Clone the frontend repo:
CODE$ git clone <repo-url> alli-frontend-media-planner alli-frontend-media-planner$ npm install
Ensure the file
alli-frontend-media-planner.js
exists in thesrc
folder.Clone the backend repo:
CODEgit clone <repo-url> alli-mediaplanner-backend alli-mediaplanner-backend$ npm install
2. Enable Import Overrides in Chrome
Enable the Import Overrides UI:
Open DevTools > Application > Local Storage.
Set the key
import-overrides-ui
totrue
.Refresh the browser page.
Add Import Override:
Open the Overrides UI Window (at the bottom of Chrome DevTools).
Click “Add override”.
Select the module
@alli/frontend-media-planner
.In the modal, enter the override URL:
CODEhttps://localhost:8081/alli-frontend-media-planner.js
Click “Apply override”.
3. Set Up the Backend
Update CORS Settings in Backend:
In
alli-mediaplanner-backend/app/index.js
, change:CODE- origin: CORS_ALLOWED_ORIGINS, + origin: "*",
Start Backend Server:
Open a terminal (VSCode's Run and Debug “JavaScript Debug Terminal” is recommended for debugging).
Run:
CODEalli-mediaplanner-backend$ aws-vault exec datawarehouse -- bin/dev/serve
In the terminal output, look for a line like:
CODE"message": "Media Planner Listening on port: 8079"
Note the port number.
4. Point Frontend to Backend
In the frontend repo
src/redux-toolkit/types.js
, update:CODE- export const MEDIA_PLAN_DOMAIN = `https://mediaplanner.${process.env.ALLI_DOMAIN}/api`; // eslint-disable-line no-undef + export const MEDIA_PLAN_DOMAIN = `http://localhost:8079/api`;
Start the frontend app
alli-frontend-media-planner$ npm run start
5. Verify Setup
Open browser and go to the staging URL:
CODEhttps://app.allistaging.com/client/demo_client/planning/media-planner/
Hit refresh. Everything should now be routed to your frontend and your backend.
After you are done testing, and want to connect to real staging environment - Remove the override (ie. Click “Disable override” in Import Overrides UI) and refresh page.