Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/homepage/commit/95635fca041a1a1e8b2979eac153b8119ec1cd7c
You should set ROOT_URL correctly, otherwise the web may not work correctly.
3 changed files with
4 additions and
38 deletions
@ -3,7 +3,6 @@ import { performance } from "perf_hooks";
import { getServiceItem } from "utils/config/service-helpers" ;
import createLogger from "utils/logger" ;
import { httpProxy } from "utils/proxy/http" ;
import { importCookieHeader } from "utils/proxy/cookie-jar" ;
const logger = createLogger ( "ping" ) ;
@ -26,24 +25,20 @@ export default async function handler(req, res) {
} ) ;
}
if ( req . headers . cookie ) {
importCookieHeader ( pingURL , req . headers . cookie )
}
try {
let startTime = performance . now ( ) ;
let [ status ] = await httpProxy ( pingURL , {
method : "HEAD"
} ) ;
let endTime = performance . now ( ) ;
if ( status > 403 ) {
// try one more time as a GET in case HEAD is rejected for whatever reason
startTime = performance . now ( ) ;
[ status ] = await httpProxy ( pingURL ) ;
endTime = performance . now ( ) ;
}
return res . status ( 200 ) . json ( {
status ,
latency : endTime - startTime
@ -37,27 +37,3 @@ export function addCookieToJar(url, headers) {
cookieJar . setCookieSync ( cookies [ i ] , url . toString ( ) , { ignoreError : true } ) ;
}
}
export function importCookieHeader ( url , cookieHeader ) {
const cookies = cookieHeader . split ( ';' ) ;
for ( let i = 0 ; i < cookies . length ; i += 1 ) {
const [ key , value ] = cookies [ i ] . trim ( ) . split ( '=' ) ;
// If there's an existing cookie with a matching key for this url,
// we want to update it. Otherwise, we add a new cookie
let existingCookie ;
try {
existingCookie = cookieJar . getCookiesSync ( url ) . find ( existing => existing . key === key ) ;
} catch ( e ) {
console . debug ( ` Failed to get cookies for ${ url } : ${ e } ` )
}
if ( existingCookie ) {
existingCookie . value = value ;
} else {
cookieJar . setCookieSync ( new Cookie ( {
key , value
} ) , url . toString ( ) , { ignoreError : true } ) ;
}
}
}
@ -4,7 +4,6 @@ import validateWidgetData from "utils/proxy/validate-widget-data";
import { httpProxy } from "utils/proxy/http" ;
import createLogger from "utils/logger" ;
import widgets from "widgets/widgets" ;
import { importCookieHeader } from "utils/proxy/cookie-jar" ;
const logger = createLogger ( "genericProxyHandler" ) ;
@ -35,18 +34,14 @@ export default async function genericProxyHandler(req, res, map) {
params . body = req . body ;
}
if ( req . headers . cookie ) {
importCookieHeader ( url , req . headers . cookie )
}
const [ status , contentType , data ] = await httpProxy ( url , params ) ;
let resultData = data ;
if ( resultData . error ? . url ) {
resultData . error . url = sanitizeErrorURL ( url ) ;
}
if ( status === 200 ) {
if ( ! validateWidgetData ( widget , endpoint , resultData ) ) {
return res . status ( status ) . json ( { error : { message : "Invalid data" , url : sanitizeErrorURL ( url ) , data : resultData } } ) ;