updated language fix and proxy config
This commit is contained in:
@@ -2,15 +2,32 @@ import axios from "axios";
|
||||
import https from "https";
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
const WEBAPI_URL =
|
||||
process.env.RELAY_ROOT ||
|
||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
||||
const PROXY_RELAY_URL =
|
||||
"https://" +
|
||||
(process.env.RELAYURI || "dev-pedw-ns.servicebus.windows.net") +
|
||||
"/" +
|
||||
(process.env.RELAYPATH || "dev-pedw-hc") +
|
||||
"/";
|
||||
//"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
||||
|
||||
// const azureHeaders = {
|
||||
// headers: {
|
||||
// "OData-MaxVersion": "4.0",
|
||||
// "OData-Version": "4.0",
|
||||
// "Accept": "application/json",
|
||||
// "Prefer": 'odata.include-annotations="*",return=representation',
|
||||
// "Content-Type": "application/json",
|
||||
// "ServiceBusAuthorization": SASToken,
|
||||
// },
|
||||
// };
|
||||
|
||||
const getSASToken = () => {
|
||||
var m_ResourceURI = "dev-pedw-ns.servicebus.windows.net";
|
||||
var m_Path = "dev-pedw-hc";
|
||||
var m_SasKey = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=";
|
||||
var m_SasKeyName = "devpedwnspolicy";
|
||||
var m_ResourceURI =
|
||||
process.env.RELAYURI || "dev-pedw-ns.servicebus.windows.net";
|
||||
var m_Path = process.env.RELAYPATH || "dev-pedw-hc";
|
||||
var m_SasKey =
|
||||
process.env.SASKEY || "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=";
|
||||
var m_SasKeyName = process.env.SASKEYNAME || "devpedwnspolicy";
|
||||
|
||||
var encodedResourceUri = encodeURIComponent(
|
||||
"https://" + m_ResourceURI + "/" + m_Path + "/"
|
||||
@@ -43,7 +60,7 @@ const getSASToken = () => {
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
console.log(req.method);
|
||||
// console.log(req.method);
|
||||
|
||||
var updateBody = {
|
||||
"pinswg_areaofsiteinhectaresdec": 21,
|
||||
@@ -65,8 +82,8 @@ export default async function ApiProxy(req, res) {
|
||||
|
||||
var configNoData = {
|
||||
method: req.method,
|
||||
//url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")",
|
||||
url: WEBAPI_URL + req.url.split("/api/proxy/")[1],
|
||||
//url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")",
|
||||
url: PROXY_RELAY_URL + req.url.split("/api/proxy/")[1],
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -79,8 +96,8 @@ export default async function ApiProxy(req, res) {
|
||||
|
||||
var config = {
|
||||
method: req.method,
|
||||
//url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")",
|
||||
url: WEBAPI_URL + req.query.route[0],
|
||||
//url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")",
|
||||
url: PROXY_RELAY_URL + req.query.route[0],
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -95,14 +112,14 @@ export default async function ApiProxy(req, res) {
|
||||
console.log(req.url.split("/api/proxy/")[1]);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
//console.log(config);
|
||||
// console.log(config);
|
||||
axios(req.method == "GET" ? configNoData : config)
|
||||
.then((response) => {
|
||||
res.statusCode = 200;
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.setHeader("Cache-Control", "max-age=1800000");
|
||||
res.end(JSON.stringify(response.data));
|
||||
//console.log("response data", response.data);
|
||||
// console.log("response data", response.data);
|
||||
resolve();
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user