Automatic choice of production and dev mode
This commit is contained in:
@@ -5,15 +5,13 @@ import { GeneralStats, Service, ServiceAddForm, ServerResponse, RegexFilter, not
|
||||
|
||||
var Buffer = require('buffer').Buffer
|
||||
|
||||
const DEBUG = false
|
||||
|
||||
const custom_url = DEBUG?"http://127.0.0.1:8080":""
|
||||
const custom_url = (!process.env.NODE_ENV || process.env.NODE_ENV === 'development')?"http://127.0.0.1:8080":""
|
||||
|
||||
export async function getapi(path:string):Promise<any>{
|
||||
return await new Promise((resolve, reject) => {
|
||||
fetch(`${custom_url}/api/${path}`,{credentials: "same-origin"})
|
||||
.then(res => {
|
||||
if(res.status == 401) window.location.reload()
|
||||
if(res.status === 401) window.location.reload()
|
||||
if(!res.ok) reject(res.statusText)
|
||||
res.json().then( res => resolve(res) ).catch( err => reject(err))
|
||||
})
|
||||
@@ -34,7 +32,7 @@ export async function postapi(path:string,data:any):Promise<any>{
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
}).then(res => {
|
||||
if(res.status == 401) window.location.reload()
|
||||
if(res.status === 401) window.location.reload()
|
||||
if(!res.ok) reject(res.statusText)
|
||||
res.json().then( res => resolve(res) ).catch( err => reject(err))
|
||||
})
|
||||
|
||||
@@ -37,7 +37,7 @@ function HomePage() {
|
||||
<LoadingOverlay visible={loader} />
|
||||
{services.length > 0?services.map( srv => <ServiceRow service={srv} key={srv.id} onClick={()=>{
|
||||
navigator("/"+srv.id)
|
||||
}} />):<><Space h="xl"/> <Title className='center-flex' align='center' order={3}>No services found! Add one clicking the "+" button above</Title>
|
||||
}} />):<><Space h="xl"/> <Title className='center-flex' align='center' order={3}>No services found! Add one clicking the "+" buttons</Title>
|
||||
<Space h="xl" /> <Space h="xl" />
|
||||
<div className='center-flex'>
|
||||
<Tooltip label="Add a new service" transition="pop" transitionDuration={200} openDelay={500} zIndex={0} transitionTimingFunction="ease" color="blue">
|
||||
|
||||
@@ -96,7 +96,7 @@ function ServiceDetails() {
|
||||
|
||||
{regexesList.length === 0?<>
|
||||
<Space h="xl" />
|
||||
<Title className='center-flex' align='center' order={3}>No regex found for this service! Add one by clicking the "+" button</Title>
|
||||
<Title className='center-flex' align='center' order={3}>No regex found for this service! Add one by clicking the "+" buttons</Title>
|
||||
<Space h="xl" /> <Space h="xl" />
|
||||
<div className='center-flex'>
|
||||
<Tooltip label="Add a new regex" zIndex={0} transition="pop" transitionDuration={200} openDelay={500} transitionTimingFunction="ease" color="blue">
|
||||
|
||||
Reference in New Issue
Block a user