Move API_ORIGIN into constants.js
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
import moment from 'moment';
|
||||
import { ansiToHtml } from 'anser';
|
||||
import { API_ORIGIN } from '../constants.js';
|
||||
|
||||
// https://github.com/janl/mustache.js/blob/master/mustache.js#L60
|
||||
const entityMap = {
|
||||
@@ -26,8 +27,6 @@ function ab2str(buf) {
|
||||
|
||||
export function create(type, id) {
|
||||
const accessToken = localStorage.token;
|
||||
const origin = import.meta.env.VITE_API_ORIGIN || window.location.origin;
|
||||
|
||||
const INITIAL_STREAM_LINES = 100;
|
||||
|
||||
let eventSource = null;
|
||||
@@ -57,7 +56,7 @@ export function create(type, id) {
|
||||
return {
|
||||
name: 'LogsModel',
|
||||
stream(lineHandler, errorHandler) {
|
||||
eventSource = new EventSource(`${origin}${streamApi}?lines=${INITIAL_STREAM_LINES}&access_token=${accessToken}`);
|
||||
eventSource = new EventSource(`${API_ORIGIN}${streamApi}?lines=${INITIAL_STREAM_LINES}&access_token=${accessToken}`);
|
||||
eventSource._lastMessage = null;
|
||||
eventSource.onerror = function ( /* uselessError */) {
|
||||
if (eventSource.readyState === EventSource.CLOSED) {
|
||||
@@ -87,7 +86,7 @@ export function create(type, id) {
|
||||
};
|
||||
},
|
||||
getDownloadUrl() {
|
||||
return `${origin}${downloadApi}?access_token=${accessToken}&format=short&lines=-1`;
|
||||
return `${API_ORIGIN}${downloadApi}?access_token=${accessToken}&format=short&lines=-1`;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user