Skip to content

Fixes for improving local development with Android Emulator #14372

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions dotcom-rendering/src/lib/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ export const EDITIONS_CROSSWORD_SCRIPT = getScriptRegex(

export const generateScriptTags = (scripts: string[]): string[] =>
scripts.filter(isString).map((script) => {
// Fix to run enable Bridget on local Android emulator
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix to enable Bridget to run on local Android sim

if (isDev ?? script.match(APPS_SCRIPT)) {
return [
`<script type="module" src="${script}"></script>`,
`<script type="module" src="${script.replace(
'localhost',
'10.0.2.2',
)}"></script>`,
].join('\n');
}

if (
script.match(WEB) ??
script.match(WEB_VARIANT_SCRIPT) ??
Expand Down
4 changes: 4 additions & 0 deletions dotcom-rendering/src/server/server.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const FRONT_URL = /^\/[a-z-/]+(?<!\.css)$/;
const TAG_PAGE_URL = /^\/(tone|series|profile)\/[a-z-]+/;
/** assets are paths like /assets/index.xxx.js */
const ASSETS_URL = /^assets\/.+\.js/;
/** android app requests to /json/version and /json/list */
const JSON_URL = /\/json\//;

//editionalise front url to uk
const editionalisefront = (url: string): string => {
Expand Down Expand Up @@ -64,6 +66,8 @@ const redirects: Handler = (req, res, next) => {

// Do not redirect assets urls
if (req.url.match(ASSETS_URL)) return next();
// Do not redirect android /json/ requests
if (req.url.match(JSON_URL)) return next();

if (req.url.match(ARTICLE_URL) ?? req.url.match(CROSSWORD_URL)) {
const url = new URL(req.url, 'https://www.theguardian.com/').toString();
Expand Down