Repository: react-native
Issue: undefined is not an object (evaluating 'window.location.href')
Labels: Needs: Repro,Needs: Attention,Type: Unsupported Version

### Description

I am getting app crash on launch for both the platform android and ios, If I run app in debug mode then it works fine and as soon as removed from debug mode app getting crashed.
I am not getting clear log specific to a library or syntext, only gettine below error.

**Error** - undefined is not an object (evaluating 'window.location.href')

**version** - "react-native": "0.72.6",

### Steps to reproduce

1. Install the node_module.
2. Install the pod.
3. run the app
4. after installation it is getting crashed before launch.

### React Native Version

0.72.6

### Affected Platforms

Runtime - Android, Runtime - iOS

### Output of `npx react-native info`

```text
System:
  OS: macOS 14.7.1
  CPU: (10) arm64 Apple M2 Pro
  Memory: 635.34 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.12.0
    path: ~/.nvm/versions/node/v20.12.0/bin/node
  Yarn: Not Found
  npm:
    version: 10.5.0
    path: ~/.nvm/versions/node/v20.12.0/bin/npm
  Watchman:
    version: 2024.04.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.2 AI-232.10300.40.2321.11668458
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 2.7.8
    path: /Users/sandeep.mahajan/.rvm/rubies/ruby-2.7.8/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 11.3.7
    wanted: 11.3.7
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.6
    wanted: 0.72.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: false
  newArchEnabled: false
```


### Stacktrace or Logs

```text
ERROR  TypeError: undefined is not an object (evaluating 'window.location.href')
 WARN  Module BiometricModule requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
 WARN  Module RCTBraintreeModule requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
 WARN  Module AppAlternateIcon requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
 WARN  Module RNDataCollector requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
 WARN  Module RNNetPerformComponent requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
 LOG  Running "VfMobileapp" with {"rootTag":1,"initialProps":{}}
 ERROR  Invariant Violation: "VfMobileapp" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
```


### Reproducer

https://github.com/aws-amplify/amplify-js/issues/4708

### Screenshots and Videos

![Simulator Screenshot - iPhone 13 Pro - 2025-01-12 at 16 55 35](https://github.com/user-attachments/assets/4e0c51d1-b53a-4b3e-9671-784cc2461b72)