how to develop/test angular in spring boot without building it - spring-boot

Maybe someone call help me to find a solution.
I have an angular app in a different folder of my git project.
Normally i use ng serve and open the frontend on its dedicated port.
I start the spring boot app on its own port and set a CORS filter to allow it.
However now that we are testing OAUTH i would like the frontend to be served be backend.
My problem is that ng serve is in memory and i dont know what would be the best option to include them into the backend.
I have tried to build them into the backend and then rebuild with mavent but that takes way to long for every small change on the frontend.

You may use a proxy which forwards requests to APIs or UI based on the Path. Something like
http://localhost:8888/api ---> [Proxy Server (localhost:8888)] ---> Spring Boot API (http://localhost:8080
http://proxy-domain.com:proxy-port/ui ---> [Proxy Server (localhost:8888)] ----> Angular App (http://localhost:4200)
For the proxy server, you can use free tools like Fiddler and have a rule there to route based on the URL patters (/api or /ui)

Related

How to configure SSL on Spring Boot - Angular app on EC2 instance

I can't get my backend to send data after switching to secure connection.
I was able to successfully configure SSL with ssl_mod on Apache web server that serves my Angular app on AWS Linux 2 instance, the site is secure - but my Spring Boot backend is not responding, it is not sending any data. When I additionally convert .crt and .key files to PK12 that Spring understands and I use it in Spring app - I get this error:
net::ERR_SSL_PROTOCOL_ERROR
I've tried using AWS Load Balancer, but same thing happens, frontend is loaded in secure environment, but backend is not sending any data even after I change backend calls from http to https://my-site.com. I've tried following documentation and added this to my backend app properties file:
server.tomcat.remoteip.remote-ip-header=x-forwarded-for
server.tomcat.remoteip.protocol-header=x-forwarded-proto
and security configuration upgraded with this:
http.requiresChannel().anyRequest().requiresSecure()...
but to no avail.
Lastly, I created a new instance on EC2 and this time I didn't configure apache for the frontend on linux, I just used SSL certificate on my backend app with following properties:
server.ssl.enabled=true
server.ssl.key-store=/etc/ssl/mydomain_com.p12
server.ssl.key-store-password=******
server.ssl.key-alias=mydomain
To no avail, now my site doesn't load at all. I'm despearate, struggling with this for a week now. What is the procedure for a full stack app? How do I do it?
Let me respond because on the same day I asked the question - I found a solution. The solution was - converting free SSL certificate with the help of this website:
https://www.sslshopper.com/ssl-converter.html
After I've plugged it in my Spring Boot app - it works. Before that, I made the conversion with OpenSSL on Windows, and it seems it was faulty. I'm so happy now... I read so many articles on this website on my one and a half year journey of learning to code - and got stuck on the last step. I'm so happy. Thank you all for this amazing website and all the help. I love you! I'm proud of being a part of this programming community... the best humor, the best people!
Peace

Who has the responsibility to handle CORS?

I'm developing a GraphQL API on Laravel for mobile and web applications. One of the frontend developer asking me to disable CORS on the server side because he cannot work with the API due to CORS problem. The Vue application on his localhost is making requests to my Test API which is on a URL.
From what I understand this isn't problem for the server side, CORS is s security measure for the server. I believe for development Vue developer need to handle this problem with adding a proxy to his localhost.
You are both responsible to get the application done and pointing fingers at one another does not solve this problem. This is not a technical problem.
Adding a proxy to the frontend development environment is one way to solve this problem. Another way is to whitelist the domain they are working on, or even putting a wildcard in there as the frontend developer suggested. CORS is a security feature, but it is meaningless for a development environment that does not contain any production data. Being able to get a development environment up and running without jumping through a lot of hoops helps productivity.
Work together. Your responsibility is to create an application, and without a frontend you are also failing at your task of delivering that application.

SSL for backend server without domain

I have a vps, where my spring boot backend is running on. The frontend is a mobile app built with the ionic framework.
The backend is built this way: in the front there is an so called resource server, which is an graphql server, which redirects the requests to rest microservices which are behind the resource server. Every microservice has is own task, which he's responsible for. (e.g. an fileupload-server which uploads/downloads files to a database). The whole application, including the frontend is secured by an keycloak instance, which is running as an docker container like the whole application, except the frontend.
Now my questions is, we dont have a domain and for some reason they wont buy one, but we wont to secure the communications over ssl/lets encrypt. But lets encrypt isn't able to create ssl certificates for ip adresses. So finnaly my question is: do you guys, know a solution to my problem which fits?
So far,
Daniel

Can I run a http server in nativescript?

Is it possible to run an in-app HTTP server with NativeScript either as a background service or as part of the foreground app itself ? I am looking to utilize a common code base across a system of applications which would communicate to a local server which handles some parts of the application's communication to my servers. Where, I intend to create a HTTP server in the app which can just serve as a REST server for the app. Is it possible ?
Thank you.
I don't think its possible since nativescript doesn't offer any module or plugin that supports the creation of http servers. First option is to look for a nativescript module in npm that supports http server creation, Second option is to create an http server using the native API's with javascript, Third and last option (which I prefer) is to make your own server using nodejs or any server side script and run that server on a certain machine then from your nativescript app you can access that server using the fetch module or the http module :)

Phonegap Web Server Configuration - Durandal App

I can't find any documentation on what type of internal server PhoneGap is running on mobile devices, whether it's Apache, IIS, or some other minified web server. I'd like to know what type of server it is and whether it can be configured to allow external communication to a server, which is rejecting the incoming requests because it doesn't have the CORS support added to it.
We have 3 options
1) Add CORS support to allow AJAX from PhoneGap device to the web servers
2) Configure the PhoneGap web server to act as a proxy
3) Add a plugin, or write a plugin, which allows a native Android function call to allow communication to the web server
If you have any experience with these or advice on which way to go, your help would be much appreciated. Thanks in advance!
There is no internal server. PhoneGap/Cordova creates a base native application with the default view as a webview. A webview is a blank version of a web browser window. There is no web server component to PhoneGap.

Resources