As I work on developing a web application, I am utilizing Cordova to package it into a mobile app. While the build process is successful, the mobile app is not displaying the actual frontend of my application.
I have conducted tests on the Cordova build, specifically examining the index.html file. Upon investigation, I discovered that although the mobile app functions correctly, there seems to be an issue with the script connection rendering properly. By simply replacing the content with "hello world," I was able to render this message in the mobile app. This suggests that the problem lies in the script connection rather than the Cordova build itself.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>AOS-INV</title>
</head>
<body>
<div id="root"></div>
<script src="/src/index.jsx" type="module"></script>
<!-- <h1>Hello World</h1> -->
</body>
</html>
Initially, I suspected that the cors origin might be the root of the issue. My web application implements cors, and I had set the origin to localhost. I have since updated the code for cors as follows:
app.use(cors({
origin: function (origin, callback) {
// Allow requests with no origin (like mobile apps or curl requests)
if (!origin) return callback(null, true);
if (/^http:\/\/localhost(:\d+)?$/.test(origin)) {
return callback(null, true);
} else {
return callback(new Error('Not allowed by CORS'));
}
},
// origin: /^http:\/\/localhost(:\d+)?$/,
credentials: true
}))
Despite these changes, the mobile app continues to face issues with correctly rendering the frontend.
The cors setup primarily focuses on requests made to my backend, rather than directly impacting the frontend. I am struggling to pinpoint the exact cause behind the rendering problems.
In terms of my development environment, I utilize Android Studio for my AVD and VSCode as my IDE, running the emulator through my terminal. Given my limited experience with Android Studio and mobile development, I am unsure how to access logs on the mobile device/emulator.
Your insights and suggestions would be highly appreciated. If any additional information is required, please do not hesitate to ask, and I will provide it promptly.