Destory api. subdomain

api.example.com --> example.com/api
This commit is contained in:
syuilo
2018-03-27 12:45:18 +09:00
parent 8eebec30b8
commit 003ecd4c58
5 changed files with 8 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import { EventEmitter } from 'eventemitter3';
import * as uuid from 'uuid';
import * as ReconnectingWebsocket from 'reconnecting-websocket';
import { apiUrl } from '../../../config';
import { wsUrl } from '../../../config';
import MiOS from '../../mios';
/**
@ -42,14 +42,13 @@ export default class Connection extends EventEmitter {
this.state = 'initializing';
this.buffer = [];
const host = apiUrl.replace('http', 'ws');
const query = params
? Object.keys(params)
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))
.join('&')
: null;
this.socket = new ReconnectingWebsocket(`${host}/${endpoint}${query ? '?' + query : ''}`);
this.socket = new ReconnectingWebsocket(`${wsUrl}/${endpoint}${query ? '?' + query : ''}`);
this.socket.addEventListener('open', this.onOpen);
this.socket.addEventListener('close', this.onClose);
this.socket.addEventListener('message', this.onMessage);

View File

@ -2,6 +2,7 @@ declare const _HOST_: string;
declare const _HOSTNAME_: string;
declare const _URL_: string;
declare const _API_URL_: string;
declare const _WS_URL_: string;
declare const _DOCS_URL_: string;
declare const _STATS_URL_: string;
declare const _STATUS_URL_: string;
@ -20,6 +21,7 @@ export const host = _HOST_;
export const hostname = _HOSTNAME_;
export const url = _URL_;
export const apiUrl = _API_URL_;
export const wsUrl = _WS_URL_;
export const docsUrl = _DOCS_URL_;
export const statsUrl = _STATS_URL_;
export const statusUrl = _STATUS_URL_;