# Build Mobile Apps with Angular, Ionic 4, and Spring Boot

**URL:** <https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078>\
**Category:** Developer Blog Comments\
**Created:** [June 20, 2019, 6:48pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078 "2019-06-20T18:48:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [June 20, 2019, 6:48pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/1 "2019-06-20T18:48:02Z")

</div>

[Build Mobile Apps with Angular, Ionic 4, and Spring Boot](https://developer.okta.com/blog/2019/06/24/ionic-4-angular-spring-boot-jhipster)

Learn how to use Ionic for JHipster to create a bad-ass PWA / mobile app that runs on iOS and Android. JWT, OIDC, and microservices are all supported!

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [June 26, 2019, 6:41pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/2 "2019-06-26T18:41:40Z")

</div>

**David Kapanga**

nice tutorial, but what if I use JWT? how do I configure the login process?. I generate an ionic on my existing jhipster project, but all I get is 403 (forbidden) when trying to login or create an account, and on my backend server I got this message  
Forbidden: Could not verify the provided CSRF token because your session was not found.  
Resolved [org.springframework.security.web.csrf.MissingCsrfTokenException: Could not verify the provided CSRF token because your session was not found.]  
do you have any idea how to solve this? because everything works on my monolith frontend angular that was generated with the backend server by jhipster but on the ionic all request are forbidden.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 7, 2019, 12:56am UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/3 "2019-07-07T00:56:59Z")

</div>

**Biswadeep Basu**

Hi Matt,

I tried following the steps mentioned in this tutorial. But I come across a CORS issue, whenever I try to login from the Ionic app. the web app login works perfectly.

I even tried to clone and execute the same set of steps mentioned in your git repo  
[https://github.com/oktadeve…](https://github.com/oktadeveloper/okta-ionic4-jhipster-example "https://github.com/oktadeveloper/okta-ionic4-jhipster-example")

But its the same error

Access to XMLHttpRequest at '[https://dev-xxxxxx.okta.com…](https://dev-xxxxxx.okta.com/oauth2/default/.well-known/openid-configuration' "https://dev-xxxxxx.okta.com/oauth2/default/.well-known/openid-configuration'") from origin ‘[http://localhost:8100](http://localhost:8100)’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Sign in error: Error: Unable To Obtain Server Configuration

[https://i.stack.imgur.com/y…](https://i.stack.imgur.com/yeuqq.png "https://i.stack.imgur.com/yeuqq.png")

I tried updating the src/main/resources/config/application.yml as shown in the below video [https://www.youtube.com/wat…](https://www.youtube.com/watch?v=eS6Ti5Ft7JE "https://www.youtube.com/watch?v=eS6Ti5Ft7JE")

I even tried the @oktadev/schematics plugin [https://www.npmjs.com/packa…](https://www.npmjs.com/package/@oktadev/schematics "https://www.npmjs.com/package/@oktadev/schematics")

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 7, 2019, 1:53pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/4 "2019-07-07T13:53:20Z")

</div>

**Biswadeep Basu**

As a work around, I have added ‘[http://localhost:8100](http://localhost:8100)’ as a trusted origin in my Okta applicaton. But a real solution will be more helpful.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 9, 2019, 3:36pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/5 "2019-07-09T15:36:11Z")

</div>

**Matt Raible**

Hello David,

If you’re using JWT, things should just work.

Are you running your JHipster app in prod mode? If so, you might need to adjust your CORS settings in `application-prod.yml`. I haven’t seen any CSRF issues.

I’d be happy to try and reproduce the problem. Can you provide the JDL for your JHipster project? Or run `jhipster info` on it and paste the output in a \<pre\>\<code\> block? If it’s easier, you can also [create a new issue in generator-jhipster-ionic](https://github.com/oktadeveloper/generator-jhipster-ionic/issues/new "https://github.com/oktadeveloper/generator-jhipster-ionic/issues/new").

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 12, 2019, 4:22pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/6 "2019-07-12T16:22:08Z")

</div>

**David Kapanga**

thank you!!! the problem was about version of Jhipster, ionic is only available for Jhipster 6.1 above, after I updated my app all works now!! Thank you.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 21, 2019, 6:32pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/7 "2019-07-21T18:32:33Z")

</div>

**Илья**

Hi Matt, how can I migrate some screens of the initially Angular website to the Ionic app, if they are some external scrips executed on the page like Stripe.js and so on? So, how can I have the same features (reacher than CRUD) on the angular and ionic apps to make them being written once, not rewritten for the ionic app (so make them being executed as a true PWA)?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 30, 2019, 4:24am UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/8 "2019-07-30T04:24:38Z")

</div>

**Matt Raible**

If you want to have pages and services that you share between your Angular and Ionic app, you’ll probably want to create a library that you can import into both projects. See Angular’s [creating libraries documentation](https://angular.io/guide/creating-libraries "https://angular.io/guide/creating-libraries") for more information.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 30, 2019, 2:10pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/9 "2019-07-30T14:10:10Z")

</div>

**Илья**

Thanks Matt. Am I right, that I will not need this when turning the angular app to the PWA? Is the example for turning the jHipster app to the PWA is available anywhere?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 30, 2019, 4:36pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/10 "2019-07-30T16:36:22Z")

</div>

**Matt Raible**

This is the correct solution. When you create a new application on Okta, the login redirect URIs you add are automatically added as trusted origins. If you add the login redirect URIs after, you need to manually add the trusted origins.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 30, 2019, 4:36pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/11 "2019-07-30T16:36:31Z")

</div>

**Matt Raible**

I converted a JHipster + React app to use JHipster last week and discovered there’s two steps (there used to only be one).

1. Uncomment the service worker in `src/main/webapp/index.html`.

```
<script> if (‘serviceWorker’ in navigator) { window.addEventListener(‘load’, function() { navigator.serviceWorker.register(’/service-worker.js’) .then(function () { console.log(‘Service Worker Registered’); }); }); }</script>
```

2. Add `https://storage.googleapis.com` to the content security policy in `SecurityConfiguration.java`

```
@EnableWebSecuritypublic class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http … .and() .headers() .contentSecurityPolicy("default-src ‘self’; script-src ‘self’ " + "‘unsafe-inline’ ‘unsafe-eval’ https://storage.googleapis.com; " + “style-src ‘self’ ‘unsafe-inline’; img-src ‘self’ data:”) .and() … }}
```

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 31, 2019, 3:13pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/12 "2019-07-31T15:13:45Z")

</div>

**Илья**

Thank you so much, Matt! Is it possible to write a separate article about it? I’m not sure that many people interested into turning the Jhipster app into PWA will find the right instruction in the comment.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 31, 2019, 3:21pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/13 "2019-07-31T15:21:09Z")

</div>

**Matt Raible**

It should be as simple as commenting out the service worker initialization code in `index.html`. The fact that it requires an addition to the CSP policy is a bug IMO. I [created a pull request to fix it](https://github.com/jhipster/generator-jhipster/pull/10169 "https://github.com/jhipster/generator-jhipster/pull/10169").

There is a section in the generated README that details how to enable PWA support. If you think more details are needed in this section, please comment on my PR.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [August 20, 2019, 6:46pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/14 "2019-08-20T18:46:31Z")

</div>

**HageneLabz**

How would you go about deploying this? I have an app that is using JWT and can communicate locally. Not sure as to how to deploy this so i can distribute an apk and it work for others.

Thanks

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [August 30, 2019, 9:08am UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/15 "2019-08-30T09:08:41Z")

</div>

**Fadi Abu Alnaser**

Thank you for this tutorial it’s very easy to understand it but I am facing a issue with navigate to root method is not work with me I spend hours trying to solve it but couldn’t found any solution.  
this pice of code not work for me this.navController.navigateRoot(’/tabs’);

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [August 30, 2019, 9:45am UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/16 "2019-08-30T09:45:06Z")

</div>

**Fadi Abu Alnaser**

it was wrong config in src/environments/environment.ts my application port was 8282 not 8080

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [November 1, 2019, 9:58pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/17 "2019-11-01T21:58:58Z")

</div>

**Matt Raible**

You should be able to deploy your JHipster backend to anyone that supports Java. Heroku, Cloud Foundry, Google Cloud, etc. For the frontend, you’ll need to [publish it in an app store for iOS and Android](https://ionicframework.com/docs/publishing/app-store "https://ionicframework.com/docs/publishing/app-store"). If you want to deploy Ionic as a PWA, you can use Firebase, Heroku, or pretty much anyone since it’s just a static site. Here’s [Ionic’s PWA publishing docs](https://ionicframework.com/docs/publishing/progressive-web-app "https://ionicframework.com/docs/publishing/progressive-web-app").

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [November 2, 2019, 12:14am UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/18 "2019-11-02T00:14:46Z")

</div>

**Matt Raible**

Biswadeep - thanks for pointing out this issue. I’ve added a section on adding `http://localhost:8100` as a trusted origin.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [February 1, 2020, 6:59am UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/19 "2020-02-01T06:59:12Z")

</div>

**李毅**

Hi Matt，may i replace angular to vue js

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [February 1, 2020, 2:49pm UTC](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078/20 "2020-02-01T14:49:07Z")

</div>

**Matt Raible**

Ionic has beta support for Vue, so it’s possible.

[https://ionicframework.com/…](https://ionicframework.com/blog/announcing-the-ionic-vue-beta/ "https://ionicframework.com/blog/announcing-the-ionic-vue-beta/")

The Ionic module for JHipster only supports Angular, so you’d have to write the code yourself.

[Next page](https://devforum.okta.com/t/build-mobile-apps-with-angular-ionic-4-and-spring-boot/17078.md?page=2)
