Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR-14438 - disable sending body if request method is 'GET' #299

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading