# Code export deployment

**URL:** <https://community.weweb.io/t/code-export-deployment/6444>\
**Category:** Ask us anything\
**Created:** [January 17, 2024, 1:16pm UTC](https://community.weweb.io/t/code-export-deployment/6444 "2024-01-17T13:16:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![myb1001](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@myb1001](https://community.weweb.io/u/myb1001)\
**Post date:** [January 17, 2024, 1:16pm UTC](https://community.weweb.io/t/code-export-deployment/6444/1 "2024-01-17T13:16:22Z")

</div>

Hi there !

Sorry if this is a very beginner question.

I have built a webapp using weweb that is using an sql database as backend using the sql plugin. (My database is currently hosted online but only accessible by the weweb ip address.)

I now need to deploy my webapp for my customer in their own datacenter. I understand that the export code function is only for the static files, but how can I now linkup my static files with my backend that connects to their local sql database and that can handle the sql requests in my webapp ?

Thank you !

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [January 17, 2024, 4:32pm UTC](https://community.weweb.io/t/code-export-deployment/6444/2 "2024-01-17T16:32:32Z")

</div>

The exported web app should continue to works. It will send request to our SQL microservice, and this microservice will forward it to your linked database (the one you configured in the editor before deploying it)

---

<div class="post-metadata">

**Author:** ![myb1001](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@myb1001](https://community.weweb.io/u/myb1001)\
**Post date:** [January 17, 2024, 7:35pm UTC](https://community.weweb.io/t/code-export-deployment/6444/3 "2024-01-17T19:35:17Z")

</div>

So if I want to use a local db in their datacenter I should change the SQL server parameters in the editor (which will not connect since there is no way to connect from the outside to my customer’s server) and export the code ? There is no way to change the sql db settings inside the exported files ?  
Thank you !

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [January 18, 2024, 10:29am UTC](https://community.weweb.io/t/code-export-deployment/6444/4 "2024-01-18T10:29:57Z")

</div>

If there is no way to connect from the outside then our microservice will not be able to reach your customer database.

We provide a way to selfhost our own server but it doesn’t include our plugin microservices, only the auth and hosting services.

You may have to put a REST API in front of your customer database if you want to connect it with a selfhosted WeWeb app.

We provided a docker snippet to some of our customers in this situation, you can check at our tool here =\> [GitHub - weweb-assets/compose-postgrest-weweb](https://github.com/weweb-assets/compose-postgrest-weweb.git)  
It use [PostgREST Documentation — PostgREST 12.0.0 documentation](https://postgrest.org/en/stable/)

It setup a REST API on top of your database an. But it’s very technical. It also provide a simple web server to host your builded app, you just have to copy paste your files in the right place and it will serve it for you (not mandatory, you can still host them elsewhere)

---

<div class="post-metadata">

**Author:** ![myb1001](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@myb1001](https://community.weweb.io/u/myb1001)\
**Post date:** [February 6, 2024, 4:08pm UTC](https://community.weweb.io/t/code-export-deployment/6444/5 "2024-02-06T16:08:44Z")

</div>

Apologies for my late reply and thank you for you reply Alexis.  
The provided solution (compose-postgrest-weweb) might not be usable as is in my case but setting up a REST API in front of my db is not a bad thing in itself.

But I have to admit that there is something that I do not fully understand here:  
My understanding now is that using the sql plugin requires our sql statements to go through a weweb microservice, therefore requiring online access to the front end hosting and the db.  
However, using a REST API does not require interaction with a weweb hosted microservice at all ?

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [February 6, 2024, 4:22pm UTC](https://community.weweb.io/t/code-export-deployment/6444/6 "2024-02-06T16:22:38Z")

</div>

That’s because we need to hide your SQL database credentials.

But for a REST API it’s not required as you can have a public API or a protected API with a mechanism to let the user authenticate and then attach the authorization token or login/password to the request dynamically, no common secret to hide.

But for some services like Airtable where you have a private API KEY it’s the same constraint, we have to hide it behind a microservice on our side. Because else it will be available in the front end and someone could steal it.

---

<div class="post-metadata">

**Author:** ![myb1001](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@myb1001](https://community.weweb.io/u/myb1001)\
**Post date:** [February 6, 2024, 4:47pm UTC](https://community.weweb.io/t/code-export-deployment/6444/7 "2024-02-06T16:47:20Z")

</div>

Makes sens ! Thank you for the swift reply.

---

<div class="post-metadata">

**Author:** ![myb1001](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@myb1001](https://community.weweb.io/u/myb1001)\
**Post date:** [February 20, 2024, 1:56am UTC](https://community.weweb.io/t/code-export-deployment/6444/8 "2024-02-20T01:56:09Z")

</div>

One last question (I hope :D) for you Alexis, I have now implemented my rest api and started working on implementing user login using a JWT Bearer Token for authentication & authorization.  
If I use the weweb Token auth system, will I be able to export the static code and login without using any weweb service ? (meaning not needing any access to the weweb hosted servers)

Thanks a lot !

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [February 22, 2024, 12:18pm UTC](https://community.weweb.io/t/code-export-deployment/6444/9 "2024-02-22T12:18:01Z")

</div>

Yes, but be aware once you export the code we are not able to secure the access to the page itself, so your page should not contain any hardcoded sensitive information inside.

But as your dynamic data are loaded dynamically with the user token, your data remain secure.

By self hosting the app, what you lose is the backend verification we do before returning the page, but it can be replaced by a simple workflow on page, checking if the user is authenticated or not, to redirect the user to the login page for example.
