Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const shop = 'shop' in proxyOptions ? proxyOptions.shop : session.shop;
const accessToken =
'password' in proxyOptions ? proxyOptions.password : session.accessToken;
const version = proxyOptions.version;
if (ctx.path !== PROXY_BASE_PATH || ctx.method !== 'POST') {
await next();
return;
}
if (accessToken == null || shop == null) {
ctx.throw(403, 'Unauthorized');
return;
}
await proxy(shop, {
https: true,
parseReqBody: false,
// Setting request header here, not response. That's why we don't use ctx.set()
// proxy middleware will grab this request header
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': accessToken,
},
proxyReqPathResolver() {
return `${GRAPHQL_PATH_PREFIX}/${version}/graphql.json`;
},
})(
ctx,
/*
We want this middleware to terminate, not fall through to the next in the chain,