Skip to content

Commit 856f1c1

Browse files
authored
fix(android): stop rewriting localhost to 10.0.2.2 (#1380)
1 parent 8ab3105 commit 856f1c1

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

‎.changeset/twenty-bushes-act.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@callstack/repack": patch
3+
---
4+
5+
Fix Android dev-server URLs on physical devices by preserving `localhost` instead of rewriting it to `10.0.2.2`.

‎packages/repack/src/modules/getDevServerLocation.ts‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
let hostname = __PUBLIC_HOST__;
2-
3-
if (__PLATFORM__ === 'android' && __PUBLIC_HOST__ === 'localhost') {
4-
hostname = '10.0.2.2';
5-
}
6-
71
const location = {
8-
host: `${hostname}:${__PUBLIC_PORT__}`,
9-
hostname,
10-
href: `${__PUBLIC_PROTOCOL__}://${hostname}:${__PUBLIC_PORT__}/`,
11-
origin: `${__PUBLIC_PROTOCOL__}://${hostname}:${__PUBLIC_PORT__}`,
2+
host: `${__PUBLIC_HOST__}:${__PUBLIC_PORT__}`,
3+
hostname: __PUBLIC_HOST__,
4+
href: `${__PUBLIC_PROTOCOL__}://${__PUBLIC_HOST__}:${__PUBLIC_PORT__}/`,
5+
origin: `${__PUBLIC_PROTOCOL__}://${__PUBLIC_HOST__}:${__PUBLIC_PORT__}`,
126
pathname: '/',
137
port: __PUBLIC_PORT__,
148
protocol: __PUBLIC_PROTOCOL__,

0 commit comments

Comments
 (0)