Only using http in dev environments
This commit is contained in:
parent
41bfd1cd89
commit
e4630199a6
@ -1,5 +1,6 @@
|
|||||||
const got = require('got')
|
const got = require('got')
|
||||||
const { Response } = require('./response.js')
|
const { Response } = require('./response.js')
|
||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -15,14 +16,19 @@ const { Response } = require('./response.js')
|
|||||||
|
|
||||||
exports.Request = async function (method, domain, port, path, params, body=null) {
|
exports.Request = async function (method, domain, port, path, params, body=null) {
|
||||||
try {
|
try {
|
||||||
// TODO: force https since actual servers do not response on port 80
|
let url = `https://${domain}:${port}${path}`
|
||||||
const url = `http://${domain}:${port}`
|
const options = {
|
||||||
let options = {
|
|
||||||
method: method,
|
method: method,
|
||||||
searchParams: params,
|
searchParams: params,
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
throwHttpErrors: false
|
throwHttpErrors: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: only in dev environments do we use http
|
||||||
|
if(process.env['DEV_ENV']) {
|
||||||
|
url = `http://${domain}:${port}${path}`
|
||||||
|
}
|
||||||
|
|
||||||
if(body) {
|
if(body) {
|
||||||
options.body = body
|
options.body = body
|
||||||
if(method == 'get') {
|
if(method == 'get') {
|
||||||
|
Loading…
Reference in New Issue
Block a user