-
Sep 30th, 2021, 02:54 PM
#1
Ionic - Cordova - Angular Monorepo
I am using Ionic and Cordova in an Angular monorepo (boy is that a mouthful). The project is structured such that there are two projects, one is an Angular library named Shared whereas the other is an Ionic project named Mobile.
Recently I had to switch from the Angular HttpClient to the Cordova @capacitor-community/http plugin. In my shared library I created a service that gets headers, chains intercepts, catches errors and submits HTTP requests using the new plugin. In my mobile project I import the service from the shared library and make a get request. I then run the following commands in my terminal to get everything ready and to open Android Studio:
Code:
cd ~/projects/[project name redacted]
npm install
ng build shared
ionic build --project=mobile
cd mobile
npx cap sync
npx cap open android
The issue is that when I would start debugging the project I would get an error in logcat with the following message:
Code:
E/Capacitor: Unable to read file at path public/plugins
I had read somewhere that the error would appear if there weren't any Cordova plugins installed for the project. A coworker took a look at it and manually added the plugin to mobile's package.json file.
Personally, I don't feel like this is right. It works, but I feel like there should be a command we should be running in the terminal rather than manually adding the dependency. What command? I don't know. But this just fails my smell test.
What are your thougts?
-
Oct 1st, 2021, 06:39 AM
#2
Re: Ionic - Cordova - Angular Monorepo
Originally Posted by dday9
I had to switch from the Angular HttpClient
to the Cordova @capacitor-community/http plugin.
Simple http-communication with your serverside API then...
Originally Posted by dday9
I feel like there should be a command we should be running in the terminal rather than manually adding the dependency. What command? I don't know. But this just fails my smell test.
What are your thougts?
Too many "layers, upon layers, upon layers", I guess.
http-communication (for contacting your serverside API via RPCs aka "Ajax-calls") is already built-into the WebView-Control (normal js-functionality).
Olaf
-
Oct 1st, 2021, 08:13 AM
#3
Re: Ionic - Cordova - Angular Monorepo
Originally Posted by Schmidt
http-communication (for contacting your serverside API via RPCs aka "Ajax-calls") is already built-into the WebView-Control (normal js-functionality).
Correct, I'm aware. Before switching to the plugin I was using the Angular HttpClient which leverages the browser's HTTP capabilities. The issue is that the client I am working for has their own security team and is responsible for the API and web server.
They do not want to mess with their current CORS policy and so for a work around I presented the @capacitor-community/http plugin.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|