'use strict';
const express = require('express');
+const fs = require('fs');
const http = require('http');
const path = require('path');
const relayServer = require('./relay-server.js');
var clientRouter = express.Router();
var httpserver, evtEmit;
var platform_app_path = '/opt/usr/globalapps';
+var platform_client_res_path = '/res/wgt/client';
var serverAppId = '';
var urlParam = '';
var g = {
console.log(`${TAG} __dirname: ${__dirname}`);
if (is_tv) {
- platform_app_path = '/opt/usr/apps'
+ platform_app_path = '/opt/usr/apps';
+ if (!fs.existsSync(path.join(__dirname, platform_client_res_path))) {
+ platform_client_res_path = '/res/wsa/client';
+ }
console.log(`${TAG} TV Profile`);
}
clientRouter.get('/*', function(req, res) {
const file = req.originalUrl.replace('/client/', '').replace(/\?.+$/, '');
const pkgId = webapis.getPackageId();
- const fullPath = require('path').join(g.baseDir, pkgId, '/res/wgt/client', file);
+ const fullPath = require('path').join(g.baseDir, pkgId, platform_client_res_path, file);
console.log(`${TAG} pkgId: ${pkgId}, fullPath: ${fullPath}`);
res.sendFile(fullPath);
});