From 1a0b51e4b489f17f4860379a34916cf0e4524b14 Mon Sep 17 00:00:00 2001 From: zeus Date: Wed, 13 Jan 2021 12:33:54 +0200 Subject: [PATCH] http changes --- Dockerfile | 2 +- src-local/llo/new.js | 19 +- src/components/mynetwork/:w | 579 ------------------------------------ src/config/index.js | 4 +- src/main.js | 30 +- 5 files changed, 26 insertions(+), 608 deletions(-) delete mode 100644 src/components/mynetwork/:w diff --git a/Dockerfile b/Dockerfile index 5b2a1bc..984f319 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,6 +65,6 @@ RUN set -uex; \ WORKDIR /home/node/swarmlab-app VOLUME /home/node/swarmlab-app -EXPOSE 443 8080 3000 +EXPOSE 443 8080 3000 3080 CMD ["pm2-runtime", "ecosystem.config.js"] diff --git a/src-local/llo/new.js b/src-local/llo/new.js index cc09abd..c7e940f 100644 --- a/src-local/llo/new.js +++ b/src-local/llo/new.js @@ -3,13 +3,16 @@ var fs = require('fs'); var express = require('express'); -var https = require('https'); +//var https = require('https'); +var http = require('http'); var app = express(); const cors = require('cors') const helmet = require('helmet'); var allowedOrigins = [ 'https://localhost:55543', + 'http://localhost:3080', + 'http://localhost:3088', 'http://localhost:8080' ]; @@ -31,14 +34,26 @@ origin: function(origin, callback){ // allow requests with no origin app.use(helmet()); app.use(express.json()); +var serverPort = 3080; +/* + // ssl enabled var options = { key: fs.readFileSync('./llo/swarmlab.key'), cert: fs.readFileSync('./llo/swarmlab.crt') }; -var serverPort = 3000; var server = https.createServer(options, app); var io = require('socket.io')(server); +*/ + +var server = http.createServer(app); +const io = require("socket.io")(server, { + cors: { + origin: "http://localhost:8080", + methods: ["GET", "POST"] + } +}); + const { spawn, exec } = require('child_process') diff --git a/src/components/mynetwork/:w b/src/components/mynetwork/:w deleted file mode 100644 index 63c22d8..0000000 --- a/src/components/mynetwork/:w +++ /dev/null @@ -1,579 +0,0 @@ - - - diff --git a/src/config/index.js b/src/config/index.js index 3b8d230..87fcf91 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -1,7 +1,7 @@ //var global_config = { export const ApiConfig = { 'swarmlab_url_80' : 'https://api.swarmlab.io', - 'url_80' : 'https://localhost:3000', // webclient - 'url_443' : 'https://localhost:3000' // webclient + 'url_80' : 'http://localhost:3080', // webclient + 'url_443' : 'https://localhost:3080' // webclient /* config for swarmlab ide */ }; diff --git a/src/main.js b/src/main.js index d18aaf3..bcdb0fd 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,7 @@ import Vue from 'vue' import App from './App.vue' import store from '@/store/index' +import {ApiConfig} from "@/config/index"; import BootstrapVue from 'bootstrap-vue' import 'bootstrap/dist/css/bootstrap.css' import 'bootstrap-vue/dist/bootstrap-vue.css' @@ -18,39 +19,20 @@ import VueSocketIOExt from 'vue-socket.io-extended'; //import io from 'socket.io-client'; import { io } from 'socket.io-client'; -/* -const socket = io('http://localhost:3000', { - //autoConnect: false, - autoConnect: true, - reconnection: true, - reconnectionDelay: 500, - maxReconnectionAttempts: Infinity, - pingInterval: 25000, - pingTimeout: 60000, - //transports: ["websocket"], - transports: [ 'websocket', 'polling' ], - //transports: ["polling"], - secure: true - //rejectUnauthorized: false -}); -*/ //const socket = io('https://factory.swarmlab.io:55527', { -const socket = io('https://localhost:3000', { -//const socket = io('https://83.212.78.17:3088', { -//const socket = io('http://factory.swarmlab.io:55528', { - //autoConnect: false +//const socket = io('https://localhost:3080', { +var socketurl = ApiConfig.url_80; +const socket = io(socketurl, { autoConnect: false, reconnection: true, reconnectionDelay: 500, maxReconnectionAttempts: Infinity, pingInterval: 25000, pingTimeout: 60000, - //transports: ["websocket"], transports: [ 'websocket', 'polling' ], - //transports: ["polling"], - secure: true - //rejectUnauthorized: false + secure: true, + rejectUnauthorized: false });