diff --git a/apps/OpenSign/Dockerhubfile b/apps/OpenSign/Dockerhubfile index 395bad9d6..6f2d22e29 100644 --- a/apps/OpenSign/Dockerhubfile +++ b/apps/OpenSign/Dockerhubfile @@ -13,6 +13,10 @@ RUN npm install # Copy the current directory contents into the container COPY apps/OpenSign/ . COPY apps/OpenSign/.husky . +COPY apps/OpenSign/entrypoint.sh . + +# make the entrypoint.sh file executable +RUN chmod +x entrypoint.sh # Define environment variables if needed ENV NODE_ENV=production @@ -20,8 +24,13 @@ ENV GENERATE_SOURCEMAP=false # build RUN npm run build +# Inject env.js loader into index.html +RUN sed -i '//a\' build/index.html + # Make port 3000 available to the world outside this container EXPOSE 3000 +ENTRYPOINT ["./entrypoint.sh"] + # Run the application CMD ["npm", "start"] diff --git a/apps/OpenSign/entrypoint.sh b/apps/OpenSign/entrypoint.sh new file mode 100644 index 000000000..91553527a --- /dev/null +++ b/apps/OpenSign/entrypoint.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +ENV_FILE=./build/env.js +DOTENV_FILE=./.env.prod # ✅ use .env.prod + +echo "Generating runtime env file at $ENV_FILE..." + +echo "window.RUNTIME_ENV = {" > $ENV_FILE + +# List of keys to include +RUNTIME_KEYS="REACT_APP_SERVERURL" + +for key in $RUNTIME_KEYS; do + # First check docker env (-e), fallback to .env file + value=$(printenv "$key") + + if [ -z "$value" ] && [ -f "$DOTENV_FILE" ]; then + # fallback: read from .env + value=$(grep "^$key=" "$DOTENV_FILE" | cut -d '=' -f2- | tr -d '\r\n' | sed 's/"/\\"/g') + else + value=$(echo "$value" | sed 's/"/\\"/g') + fi + + echo " $key: \"$value\"," >> $ENV_FILE +done + +echo "};" >> $ENV_FILE + +exec "$@" diff --git a/apps/OpenSign/public/locales/de/translation.json b/apps/OpenSign/public/locales/de/translation.json index 39bfb31e8..528ef2d27 100644 --- a/apps/OpenSign/public/locales/de/translation.json +++ b/apps/OpenSign/public/locales/de/translation.json @@ -675,7 +675,7 @@ "public-template-mssg-1": "Um OpenSign in Ihr React- oder Next.js-Projekt zu integrieren, führen Sie einfach den folgenden Befehl aus:", "public-template-mssg-2": "Stellen Sie sicher, dass npm oder yarn in Ihrem Projekt eingerichtet ist. Wenn Sie Yarn verwenden, können Sie npm install durch yarn add @opensign/react ersetzen.", "public-template-mssg-3": "Benötigen Sie weitere Details oder Beispiele?", - "public-template-mssg-4": "Besuchen Sie die", + "public-template-mssg-4": "Besuchen Sie die ", "public-template-mssg-5": " npm für die neuesten Updates, detaillierte Dokumentationen und Versionshistorie.", "public-template-mssg-6": "Bevor Sie diesen Code-Schnipsel verwenden können, müssen Sie diese Vorlage öffentlich machen.", "public-template-mssg-7": "Bevor Sie einen öffentlichen Link generieren können, müssen Sie diese Vorlage öffentlich machen.", diff --git a/apps/OpenSign/public/locales/en/translation.json b/apps/OpenSign/public/locales/en/translation.json index 1f493bf0b..8fac2c011 100644 --- a/apps/OpenSign/public/locales/en/translation.json +++ b/apps/OpenSign/public/locales/en/translation.json @@ -675,7 +675,7 @@ "public-template-mssg-1": "To integrate OpenSign into your React or Next.js project, simply run the following command:", "public-template-mssg-2": "Ensure you have npm or yarn set up in your project. If you're using Yarn, you can replace npm install with yarn add @opensign/react.", "public-template-mssg-3": "Need more details or examples?", - "public-template-mssg-4": "Visit the", + "public-template-mssg-4": "Visit the ", "public-template-mssg-5": " npm for the latest updates, detailed documentation, and version history.", "public-template-mssg-6": "Before you can use this code snippet, you must make this template public.", "public-template-mssg-7": "Before you can generate a public link you must make this template public.", diff --git a/apps/OpenSign/public/locales/es/translation.json b/apps/OpenSign/public/locales/es/translation.json index e224ef784..c4d3d0473 100644 --- a/apps/OpenSign/public/locales/es/translation.json +++ b/apps/OpenSign/public/locales/es/translation.json @@ -675,7 +675,7 @@ "public-template-mssg-1": "Para integrar OpenSign a tu proyecto React o Next.js, simplemente ejecuta los siguientes comandos:", "public-template-mssg-2": "Asegúrate de tener «npm» o «yarn» configurado en tu proyecto. Si estás usando «yarn», puedes reemplazar «npm install» con «yarn add @opensign/react».", "public-template-mssg-3": "¿Necesitas más detalles o ejemplos?", - "public-template-mssg-4": "Visita la", + "public-template-mssg-4": "Visita la ", "public-template-mssg-5": " «npm» para las últimas actualizaciones, documentación detallada e historial de versiones.", "public-template-mssg-6": "Antes de que puedas usar este fragmento de código, debes convertir esta plantilla en pública.", "public-template-mssg-7": "Antes de poder generar un enlace público, debes hacer que esta plantilla sea pública.", diff --git a/apps/OpenSign/public/locales/fr/translation.json b/apps/OpenSign/public/locales/fr/translation.json index a2ae43c17..5b5c9fec0 100644 --- a/apps/OpenSign/public/locales/fr/translation.json +++ b/apps/OpenSign/public/locales/fr/translation.json @@ -675,7 +675,7 @@ "public-template-mssg-1": "Pour intégrer OpenSign dans votre projet React ou Next.js, exécutez simplement la commande suivante :", "public-template-mssg-2": "Assurez-vous que npm ou Yarn est configuré dans votre projet. Si vous utilisez Yarn, vous pouvez remplacer npm install par Yarn Add @opensign/react.", "public-template-mssg-3": "Besoin de plus de détails ou d'exemples ?", - "public-template-mssg-4": "Visitez le", + "public-template-mssg-4": "Visitez le ", "public-template-mssg-5": "npm pour les dernières mises à jour, une documentation détaillée et l'historique des versions.", "public-template-mssg-6": "Avant de pouvoir utiliser cet extrait de code, vous devez rendre ce modèle public.", "public-template-mssg-7": "Avant de pouvoir générer un lien public, vous devez rendre ce modèle public.", diff --git a/apps/OpenSign/public/locales/it/translation.json b/apps/OpenSign/public/locales/it/translation.json index bb44b7f33..4c0ddd0c5 100644 --- a/apps/OpenSign/public/locales/it/translation.json +++ b/apps/OpenSign/public/locales/it/translation.json @@ -675,7 +675,7 @@ "public-template-mssg-1": "Per integrare OpenSign nel tuo progetto React o Next.js, esegui semplicemente il seguente comando:", "public-template-mssg-2": "Assicurati di avere npm o yarn configurato nel tuo progetto. Se usi Yarn, puoi sostituire npm install con yarn add @opensign/react.", "public-template-mssg-3": "Hai bisogno di maggiori dettagli o esempi?", - "public-template-mssg-4": "Visita il", + "public-template-mssg-4": "Visita il ", "public-template-mssg-5": " npm per gli aggiornamenti più recenti, documentazione dettagliata e cronologia delle versioni.", "public-template-mssg-6": "Prima di poter utilizzare questo frammento di codice, devi rendere questo modello pubblico.", "public-template-mssg-7": "Prima di poter generare un link pubblico, devi rendere questo modello pubblico.", diff --git a/apps/OpenSign/src/constant/Utils.jsx b/apps/OpenSign/src/constant/Utils.jsx index cdff6fa16..666db46cc 100644 --- a/apps/OpenSign/src/constant/Utils.jsx +++ b/apps/OpenSign/src/constant/Utils.jsx @@ -21,6 +21,9 @@ export const isTabAndMobile = window.innerWidth < 1023; export const textInputWidget = "text input"; export const textWidget = "text"; export const radioButtonWidget = "radio button"; +export function getEnv() { + return window?.RUNTIME_ENV || {}; +} //function for create list of year for date widget @@ -3066,7 +3069,7 @@ export const mailTemplate = (param) => { "Note" + param.note + "

This is an automated email from " + appName + ". For any queries regarding this email, please contact the sender " + diff --git a/apps/OpenSign/src/constant/appinfo.js b/apps/OpenSign/src/constant/appinfo.js index a41cff14c..f8e615f5b 100644 --- a/apps/OpenSign/src/constant/appinfo.js +++ b/apps/OpenSign/src/constant/appinfo.js @@ -1,9 +1,12 @@ import logo from "../assets/images/logo.png"; +import { getEnv } from "./Utils"; export function serverUrl_fn() { - let baseUrl = process.env.REACT_APP_SERVERURL - ? process.env.REACT_APP_SERVERURL - : window.location.origin + "/api/app"; + const env = getEnv(); + const serverurl = env?.REACT_APP_SERVERURL + ? env.REACT_APP_SERVERURL // env.REACT_APP_SERVERURL is used for prod + : process.env.REACT_APP_SERVERURL; // process.env.REACT_APP_SERVERURL is used for dev (locally) + let baseUrl = serverurl ? serverurl : window.location.origin + "/api/app"; return baseUrl; } export const appInfo = { diff --git a/apps/OpenSign/src/pages/PdfRequestFiles.jsx b/apps/OpenSign/src/pages/PdfRequestFiles.jsx index cc257b470..e7ea83e8c 100644 --- a/apps/OpenSign/src/pages/PdfRequestFiles.jsx +++ b/apps/OpenSign/src/pages/PdfRequestFiles.jsx @@ -929,7 +929,7 @@ function PdfRequestFiles( receiver_phone: user?.Phone || "", expiry_date: localExpireDate, company_name: orgName, - signing_url: `Sign here` + signing_url: signPdf }; replaceVar = replaceMailVaribles( requestSubject, @@ -944,7 +944,7 @@ function PdfRequestFiles( title: documentName, organization: orgName, localExpireDate: localExpireDate, - sigingUrl: signPdf + signingUrl: signPdf }; let params = { replyto: senderEmail || "", diff --git a/apps/OpenSign/src/pages/PlaceHolderSign.jsx b/apps/OpenSign/src/pages/PlaceHolderSign.jsx index 778540d19..e746b7ec4 100644 --- a/apps/OpenSign/src/pages/PlaceHolderSign.jsx +++ b/apps/OpenSign/src/pages/PlaceHolderSign.jsx @@ -1220,7 +1220,7 @@ function PlaceHolderSign() { receiver_phone: signerMail[i]?.Phone || "", expiry_date: localExpireDate, company_name: orgName, - signing_url: `Sign here` + signing_url: signPdf }; replaceVar = replaceMailVaribles( requestSubject, @@ -1249,7 +1249,7 @@ function PlaceHolderSign() { receiver_phone: signerMail[i]?.Phone || "", expiry_date: localExpireDate, company_name: orgName, - signing_url: `Sign here` + signing_url: signPdf }; replaceVar = replaceMailVaribles(mailSubject, htmlReqBody, variables); } @@ -1260,7 +1260,7 @@ function PlaceHolderSign() { title: documentName, organization: orgName, localExpireDate: localExpireDate, - sigingUrl: signPdf + signingUrl: signPdf }; let params = { extUserId: owner?.objectId, diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.jsx b/apps/OpenSign/src/primitives/GetReportDisplay.jsx index 880d3a128..e4f255e3e 100644 --- a/apps/OpenSign/src/primitives/GetReportDisplay.jsx +++ b/apps/OpenSign/src/primitives/GetReportDisplay.jsx @@ -679,7 +679,7 @@ const ReportTable = (props) => { receiver_phone: userDetails?.Phone || "", expiry_date: localExpireDate, company_name: doc.ExtUserPtr.Company, - signing_url: `Sign here` + signing_url: signPdf }; const res = replaceMailVaribles(subject, "", variables); setMail((prev) => ({ ...prev, subject: res.subject })); @@ -710,7 +710,7 @@ const ReportTable = (props) => { receiver_phone: userDetails?.Phone || "", expiry_date: localExpireDate, company_name: doc.ExtUserPtr.Company, - signing_url: `Sign here` + signing_url: signPdf }; const res = replaceMailVaribles("", body, variables); @@ -754,7 +754,7 @@ const ReportTable = (props) => { receiver_phone: user?.signerPtr?.Phone || "", expiry_date: localExpireDate, company_name: doc?.ExtUserPtr?.Company || "", - signing_url: `Sign here` + signing_url: signPdf }; const subject = doc?.RequestSubject || diff --git a/apps/OpenSignServer/Utils.js b/apps/OpenSignServer/Utils.js index a4c2e8184..b774f0656 100644 --- a/apps/OpenSignServer/Utils.js +++ b/apps/OpenSignServer/Utils.js @@ -252,7 +252,7 @@ export const mailTemplate = param => { "Note" + param.note + "

This is an automated email from " + AppName + '. For any queries regarding this email, please contact the sender ' + diff --git a/apps/OpenSignServer/cloud/parsefunction/Newsletter.js b/apps/OpenSignServer/cloud/parsefunction/Newsletter.js index e26c8d97e..50cf7d9db 100644 --- a/apps/OpenSignServer/cloud/parsefunction/Newsletter.js +++ b/apps/OpenSignServer/cloud/parsefunction/Newsletter.js @@ -4,9 +4,9 @@ export default async function Newsletter(request) { const email = request.params?.email?.toLowerCase()?.replace(/\s/g, ''); const domain = request.params.domain; try { - const envAppId = process.env.REACT_APP_APPID || 'opensign'; + const envAppId = 'opensign'; const headers = { 'Content-Type': 'application/json', 'X-Parse-Application-Id': envAppId }; - const envProdServer = process.env.REACT_APP_SERVERURL || 'https://app.opensignlabs.com/api/app'; + const envProdServer = 'https://app.opensignlabs.com/api/app'; const newsletter = await axios.post( `${envProdServer}/classes/Newsletter`, { Name: name, Email: email, Domain: domain }, diff --git a/apps/OpenSignServer/cloud/parsefunction/createBatchDocs.js b/apps/OpenSignServer/cloud/parsefunction/createBatchDocs.js index 03f6dbcc5..8de4db49d 100644 --- a/apps/OpenSignServer/cloud/parsefunction/createBatchDocs.js +++ b/apps/OpenSignServer/cloud/parsefunction/createBatchDocs.js @@ -14,8 +14,7 @@ async function deductcount(docsCount, extUserId) { } async function sendMail(document, publicUrl) { //sessionToken - const baseUrl = new URL(publicUrl); //process.env.PUBLIC_URL - + const baseUrl = new URL(publicUrl); // console.log("pdfDetails", pdfDetails); const timeToCompleteDays = document?.TimeToCompleteDays || 15; const ExpireDate = new Date(document.createdAt); @@ -71,7 +70,7 @@ async function sendMail(document, publicUrl) { receiver_phone: existSigner?.Phone || '', expiry_date: localExpireDate, company_name: orgName, - signing_url: `Sign here`, + signing_url: signPdf, }; replaceVar = replaceMailVaribles(mailSubject, htmlReqBody, variables); } @@ -82,7 +81,7 @@ async function sendMail(document, publicUrl) { title: document.Name, organization: orgName, localExpireDate: localExpireDate, - sigingUrl: signPdf, + signingUrl: signPdf, }; let params = { extUserId: document.ExtUserPtr.objectId, diff --git a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js index 661452107..63bac492e 100644 --- a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js +++ b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.js @@ -116,7 +116,7 @@ async function sendNotifyMail(doc, signUser, mailProvider, publicUrl) { const creatorEmail = doc.ExtUserPtr.Email; const signerName = signUser.Name; const signerEmail = signUser.Email; - const viewDocUrl = `${publicUrl}/recipientSignPdf/${doc.objectId}`; // ` ${process.env.PUBLIC_URL}/recipientSignPdf/${doc.objectId}`; + const viewDocUrl = `${publicUrl}/recipientSignPdf/${doc.objectId}`; const subject = `Document "${pdfName}" has been signed by ${signerName}`; const body = "

" + diff --git a/apps/OpenSignServer/index.js b/apps/OpenSignServer/index.js index 472e74ec8..209d07d67 100644 --- a/apps/OpenSignServer/index.js +++ b/apps/OpenSignServer/index.js @@ -161,7 +161,7 @@ app.use(express.urlencoded({ limit: '50mb', extended: true })); app.use(function (req, res, next) { req.headers['x-real-ip'] = getUserIP(req); const publicUrl = 'https://' + req?.get('host'); - req.headers['public_url'] = publicUrl; // process.env.PUBLIC_URL + req.headers['public_url'] = publicUrl; next(); }); function getUserIP(request) {