Skip to content

Commit

Permalink
FR-14438 - disable sending body if request method is GET
Browse files Browse the repository at this point in the history
  • Loading branch information
frontegg-david committed Dec 4, 2023
1 parent 6317642 commit f3983b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/nextjs/src/middleware/ProxyRequestCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const logger = fronteggLogger.child({ tag: 'FronteggApiMiddleware.ProxyRequestCa
const ProxyRequestCallback: ProxyReqCallback<ClientRequest, NextApiRequest> = (proxyReq, req) => {
try {
logger.info(`${req.url} | Going to proxy request`);
logger.info('The original req headers are', {headers: req.headers});
logger.info('The original req headers are', { headers: req.headers });
logger.debug(`${req.url} | parsing request cookies`);
const allCookies = CookieManager.parseCookieHeader(req);
logger.debug(`${req.url} | found ${allCookies} cookies`);
Expand Down Expand Up @@ -59,7 +59,7 @@ const ProxyRequestCallback: ProxyReqCallback<ClientRequest, NextApiRequest> = (p
].map((header) => proxyReq.removeHeader(header));

logger.debug(`${req.url} | check if request has body`);
if (req.body) {
if (req.method !== 'GET' && req.body) {
logger.debug(`${req.url} | writing request body to proxyReq`);
const bodyData = JSON.stringify(req.body);
// in case if content-type is application/x-www-form-urlencoded -> we need to change to application/json
Expand Down

0 comments on commit f3983b9

Please sign in to comment.