<p>I have react frontend and spring boot backend with mongodb behind.</p>

<p>I have issues with setting 2 parameters in the spring boot service.</p>

<p>First is address of the mongodb which is now set as localhost:27017 in the application.properties
It works at localhost but since I plan to scale out  using kubernetes and docker images i would like to know how to define
It and where for the case in which I have mongo1 mongo2 and mongo3 database hosts and would like to pass all 3 URIs ?</p>

<p>Second issues is more tricky! React frontend doesnt work in chrome until I put allow cross origin anotation over my spring rest endpoint . I used hardcoded localhost:3000 here but when I scale it out using kubernetes this wont work if it gets data from another host in the cluster.What to do here?</p>

Mark O
<ol>
<li><p>To answer your first question, you can configure multi data sources, see here documentation how you can configure more than one data sources (<a href="https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html" rel="nofollow noreferrer">80.2 Configure Two DataSources</a>.</p></li>
<li><p>For second question you can simply wildcard <code>CORS URL</code> or if you know all of your front end server urls which are load balanced you can pass as list of cors url.</p>

<pre><code>– * – means that all origins are allowed.

– If undefined, all origins are allowed.
</code></pre></li>
</ol>

<p><strong>RECOMMENDATION</strong></p>

<p>Run your react via <code>yarn</code> to deploy on <code>Apache</code> or <code>ngnix</code>. Once you seted up your domain or sub domain for front end, load balanced your front end so not required to run your front end on ports..</p>
