Other Articles in the Series
What Can I Get From This Article?In this article, I will introduce how to deploy the app to production environment in 2 modes:
What Should I Do To Deploy Client and API in Separated Domain?OK, for deploying the client and Api on different domains is rather simple as below:
1. Update Configuration (in app.common/configurations/configuration.release.config) for Production EnvironmentOpen your code in Visual Studio and navigate to "configurations/configuration.release.config" in Hide Shrink ![]() <?xml version="1.0" encoding="utf-8" ?>
<appconfiguration>
<authentication tokenExpiredAfterInMinute="20" ></authentication>
<paging pageSize="10"></paging>
<databases>
<clear />
<add name="DefaultConnection"
database="MyERP" server="<server>" port="<port>"
userName="<username>" password="<pwd>"
dbType="MSSQL" default="true"></add>
</databases>
<localization defaultLanguageCode="en"></localization>
<uitest reportTemplate="templates/report.xlsx"
notificationReceiver="thanhtuit27@gmail.com"
zipFile="report_{0}.zip" environtmenFile="environments.xml"
basePath="C:\data\projects\myERP\api\App.UI.Test\config\"
baseOutput="C:\data\projects\myERP\api\App.UI.Test\output\"
timeout="10"></uitest>
<mail server="smtp.gmail.com" port="587"
ssl="true" username="techcoaching123465789@gmail.com "
password="pwd" displayName="No-reply"
defaultSender="techcoaching123465789@gmail.com " />
<folder mailTemplate="templates/email/"
baseResourceFolder="C:\data\projects\myERP\api\App.UI.Test/resources/"></folder>
</appconfiguration>
Please be aware of Please update appropriate information as sample below: Hide Copy Code <add name="DefaultConnection"
database="MyERP" server="localhost" port="1433"
userName="tinyerp" password="123456"
dbType="MSSQL" default="true"></add>
2. Publish Code of API using Visual Studio Editor
The publish code was located at <solution root>/application.api/published. To deploy the API, just upload this to API domain (for example: 3. Upload API code to API DomainUsing any FTP client to upload published file to your domain: Access to 4. Update ApiBaseUrl in app/config/appConfig.ts Point to API DomainPlease change the 5. Build Client SideOpen command prompt/ terminal and go to "<root>/client/", and run " After this command was finished, the compiled code was located in "<root>/client/dist" folder: Look at this folder, all ts files were compiled into js files and were compressed into "<root>/client/dist/bundle.js". The remaining are html/ image files. Open the "<root>/client/dist/bundle.js", we see the content was compressed: We can also apply some minification during the compile process. So the code is safe to be delivered. 6. Upload Client to Domain for Client SidePlease use any FTP client tool, such as filezilla and upload those files into your domain (for example ""). Then, we can check it by access to "http://". The result is the photo below: Login with " Congratulations! You deployed your client successfully. I Got An Error as Below on IIS, How Can I Solve It?If looked at "<root>/client/dist", there is web.config file. We need this file when deploying the app on IIS. There is rewrite rule in web.config, this will always redirect the request to index.html. Hide Copy Code <rewrite>
<rules>
<rule name="Rewrite to default"
enabled="true" stopProcessing="true">
<match url="^[^.]+$" />
<conditions>
<add input="/api/" pattern="^OFF$"/>
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
Without this rule, IIS may not be able to handle request when user accesses "/security/permissions". To solve this, we need to install " I Got An Exception When Installing "Url Rewrite Module" on IIS?This mostly related to IIS issue. Please refer to this link for solving this problem. What Should I Do to Deploy Client and API in the Same Domain?To deploy API and client on the same domain, it was mostly the same as in separated domain. The compiled Api code was uploaded to the sample folder with client with some modifications:
The final folder will be: |
|