@frontegg/nextjs 8.0.8 → 8.0.9-alpha.7086267916
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/index.js +1 -1
- package/middleware/ProxyRequestCallback.js +1 -1
- package/middleware/ProxyRequestCallback.js.map +1 -1
- package/package.json +1 -1
- package/sdkVersion.js +1 -1
- package/sdkVersion.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
## [8.0.9](https://github.com/frontegg/frontegg-nextjs/compare/v8.0.8...v8.0.9) (2023-12-4)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### NextJS Wrapper 8.0.9:
|
|
7
|
+
- FR-14438 - disable sending body if request method is 'GET'
|
|
1
8
|
# Change Log
|
|
2
9
|
|
|
3
10
|
## [8.0.8](https://github.com/frontegg/frontegg-nextjs/compare/v8.0.7...v8.0.8) (2023-11-29)
|
package/index.js
CHANGED
|
@@ -54,7 +54,7 @@ const ProxyRequestCallback = (proxyReq, req) => {
|
|
|
54
54
|
}
|
|
55
55
|
['x-invoke-path', 'x-invoke-query', 'x-middleware-invoke', 'x-middleware-next', 'transfer-encoding', 'cache-control'].map(header => proxyReq.removeHeader(header));
|
|
56
56
|
logger.debug(`${req.url} | check if request has body`);
|
|
57
|
-
if (req.body) {
|
|
57
|
+
if (req.method !== 'GET' && req.body) {
|
|
58
58
|
logger.debug(`${req.url} | writing request body to proxyReq`);
|
|
59
59
|
const bodyData = JSON.stringify(req.body);
|
|
60
60
|
// in case if content-type is application/x-www-form-urlencoded -> we need to change to application/json
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProxyRequestCallback.js","names":["_package","_interopRequireDefault","require","_sdkVersion","_config","_cookies","_fronteggLogger","logger","fronteggLogger","child","tag","ProxyRequestCallback","proxyReq","req","_req$headers$xFronte","_req$headers$xFronte2","info","url","headers","debug","allCookies","CookieManager","parseCookieHeader","fronteggCookiesNames","Object","keys","filter","cookieName","startsWith","config","join","forEach","setHeader","NextJsPkg","version","sdkVersion","xForwardedFor","xOriginalForwardedFor","cfConnectionIp","map","header","removeHeader","body","bodyData","JSON","stringify","Buffer","byteLength","write","e","error","_default","exports","default"],"sources":["../../../../packages/nextjs/src/middleware/ProxyRequestCallback.ts"],"sourcesContent":["import NextJsPkg from 'next/package.json';\nimport { ProxyReqCallback } from 'http-proxy';\nimport { ClientRequest } from 'http';\nimport { NextApiRequest } from 'next';\nimport sdkVersion from '../sdkVersion';\nimport config from '../config';\nimport CookieManager from '../utils/cookies';\nimport fronteggLogger from '../utils/fronteggLogger';\n\nconst logger = fronteggLogger.child({ tag: 'FronteggApiMiddleware.ProxyRequestCallback' });\n/**\n * Proxy request callback fired on before each request to Frontegg services,\n * to transport frontegg cookies.\n *\n * @param {ClientRequest} proxyReq - Proxy request to be sent\n * @param {NextApiRequest} req - Next.js incoming request\n */\nconst ProxyRequestCallback: ProxyReqCallback<ClientRequest, NextApiRequest> = (proxyReq, req) => {\n try {\n logger.info(`${req.url} | Going to proxy request`);\n logger.info('The original req headers are', {headers: req.headers});\n logger.debug(`${req.url} | parsing request cookies`);\n const allCookies = CookieManager.parseCookieHeader(req);\n logger.debug(`${req.url} | found ${allCookies} cookies`);\n const fronteggCookiesNames = Object.keys(allCookies).filter((cookieName) => {\n return cookieName.startsWith('fe_') && !cookieName.startsWith(config.cookieName);\n });\n\n logger.debug(`${req.url} | proxy FronteggCookies (${fronteggCookiesNames.join(', ')})`);\n fronteggCookiesNames.forEach((cookieName: string) => {\n proxyReq.setHeader(cookieName, allCookies[cookieName]);\n });\n\n proxyReq.setHeader('x-frontegg-framework', req.headers['x-frontegg-framework'] ?? `next@${NextJsPkg.version}`);\n proxyReq.setHeader('x-frontegg-sdk', req.headers['x-frontegg-sdk'] ?? `@frontegg/nextjs@${sdkVersion.version}`);\n proxyReq.setHeader('x-frontegg-middleware', 'true');\n\n const xForwardedFor = req.headers['x-forwarded-for'];\n const xOriginalForwardedFor = req.headers['x-original-forwarded-for'];\n const cfConnectionIp = req.headers['cf-connecting-ip'];\n\n if (xForwardedFor) {\n proxyReq.setHeader('x-forwarded-for', xForwardedFor);\n }\n if (xOriginalForwardedFor) {\n proxyReq.setHeader('x-original-forwarded-for', xOriginalForwardedFor);\n }\n if (cfConnectionIp) {\n proxyReq.setHeader('cf-connecting-ip', cfConnectionIp);\n }\n\n [\n 'x-invoke-path',\n 'x-invoke-query',\n 'x-middleware-invoke',\n 'x-middleware-next',\n 'transfer-encoding',\n 'cache-control',\n ].map((header) => proxyReq.removeHeader(header));\n\n logger.debug(`${req.url} | check if request has body`);\n if (req.body) {\n logger.debug(`${req.url} | writing request body to proxyReq`);\n const bodyData = JSON.stringify(req.body);\n // in case if content-type is application/x-www-form-urlencoded -> we need to change to application/json\n proxyReq.setHeader('Content-Type', 'application/json');\n proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));\n // stream the content\n proxyReq.write(bodyData);\n }\n } catch (e) {\n logger.error(`${req.url} | Failed to proxy request`, e);\n }\n};\n\nexport default ProxyRequestCallback;\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,eAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,MAAMK,MAAM,GAAGC,uBAAc,CAACC,KAAK,CAAC;EAAEC,GAAG,EAAE;AAA6C,CAAC,CAAC;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAqE,GAAGA,CAACC,QAAQ,EAAEC,GAAG,KAAK;EAC/F,IAAI;IAAA,IAAAC,oBAAA,EAAAC,qBAAA;IACFR,MAAM,CAACS,IAAI,CAAE,GAAEH,GAAG,CAACI,GAAI,2BAA0B,CAAC;IAClDV,MAAM,CAACS,IAAI,CAAC,8BAA8B,EAAE;
|
|
1
|
+
{"version":3,"file":"ProxyRequestCallback.js","names":["_package","_interopRequireDefault","require","_sdkVersion","_config","_cookies","_fronteggLogger","logger","fronteggLogger","child","tag","ProxyRequestCallback","proxyReq","req","_req$headers$xFronte","_req$headers$xFronte2","info","url","headers","debug","allCookies","CookieManager","parseCookieHeader","fronteggCookiesNames","Object","keys","filter","cookieName","startsWith","config","join","forEach","setHeader","NextJsPkg","version","sdkVersion","xForwardedFor","xOriginalForwardedFor","cfConnectionIp","map","header","removeHeader","method","body","bodyData","JSON","stringify","Buffer","byteLength","write","e","error","_default","exports","default"],"sources":["../../../../packages/nextjs/src/middleware/ProxyRequestCallback.ts"],"sourcesContent":["import NextJsPkg from 'next/package.json';\nimport { ProxyReqCallback } from 'http-proxy';\nimport { ClientRequest } from 'http';\nimport { NextApiRequest } from 'next';\nimport sdkVersion from '../sdkVersion';\nimport config from '../config';\nimport CookieManager from '../utils/cookies';\nimport fronteggLogger from '../utils/fronteggLogger';\n\nconst logger = fronteggLogger.child({ tag: 'FronteggApiMiddleware.ProxyRequestCallback' });\n/**\n * Proxy request callback fired on before each request to Frontegg services,\n * to transport frontegg cookies.\n *\n * @param {ClientRequest} proxyReq - Proxy request to be sent\n * @param {NextApiRequest} req - Next.js incoming request\n */\nconst ProxyRequestCallback: ProxyReqCallback<ClientRequest, NextApiRequest> = (proxyReq, req) => {\n try {\n logger.info(`${req.url} | Going to proxy request`);\n logger.info('The original req headers are', { headers: req.headers });\n logger.debug(`${req.url} | parsing request cookies`);\n const allCookies = CookieManager.parseCookieHeader(req);\n logger.debug(`${req.url} | found ${allCookies} cookies`);\n const fronteggCookiesNames = Object.keys(allCookies).filter((cookieName) => {\n return cookieName.startsWith('fe_') && !cookieName.startsWith(config.cookieName);\n });\n\n logger.debug(`${req.url} | proxy FronteggCookies (${fronteggCookiesNames.join(', ')})`);\n fronteggCookiesNames.forEach((cookieName: string) => {\n proxyReq.setHeader(cookieName, allCookies[cookieName]);\n });\n\n proxyReq.setHeader('x-frontegg-framework', req.headers['x-frontegg-framework'] ?? `next@${NextJsPkg.version}`);\n proxyReq.setHeader('x-frontegg-sdk', req.headers['x-frontegg-sdk'] ?? `@frontegg/nextjs@${sdkVersion.version}`);\n proxyReq.setHeader('x-frontegg-middleware', 'true');\n\n const xForwardedFor = req.headers['x-forwarded-for'];\n const xOriginalForwardedFor = req.headers['x-original-forwarded-for'];\n const cfConnectionIp = req.headers['cf-connecting-ip'];\n\n if (xForwardedFor) {\n proxyReq.setHeader('x-forwarded-for', xForwardedFor);\n }\n if (xOriginalForwardedFor) {\n proxyReq.setHeader('x-original-forwarded-for', xOriginalForwardedFor);\n }\n if (cfConnectionIp) {\n proxyReq.setHeader('cf-connecting-ip', cfConnectionIp);\n }\n\n [\n 'x-invoke-path',\n 'x-invoke-query',\n 'x-middleware-invoke',\n 'x-middleware-next',\n 'transfer-encoding',\n 'cache-control',\n ].map((header) => proxyReq.removeHeader(header));\n\n logger.debug(`${req.url} | check if request has body`);\n if (req.method !== 'GET' && req.body) {\n logger.debug(`${req.url} | writing request body to proxyReq`);\n const bodyData = JSON.stringify(req.body);\n // in case if content-type is application/x-www-form-urlencoded -> we need to change to application/json\n proxyReq.setHeader('Content-Type', 'application/json');\n proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));\n // stream the content\n proxyReq.write(bodyData);\n }\n } catch (e) {\n logger.error(`${req.url} | Failed to proxy request`, e);\n }\n};\n\nexport default ProxyRequestCallback;\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,eAAA,GAAAL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,CAACjC,GAAG,CAAC8B,IAAI,CAAC;MACzC;MACA/B,QAAQ,CAACoB,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC;MACtDpB,QAAQ,CAACoB,SAAS,CAAC,gBAAgB,EAAEe,MAAM,CAACC,UAAU,CAACJ,QAAQ,CAAC,CAAC;MACjE;MACAhC,QAAQ,CAACqC,KAAK,CAACL,QAAQ,CAAC;IAC1B;EACF,CAAC,CAAC,OAAOM,CAAC,EAAE;IACV3C,MAAM,CAAC4C,KAAK,CAAE,GAAEtC,GAAG,CAACI,GAAI,4BAA2B,EAAEiC,CAAC,CAAC;EACzD;AACF,CAAC;AAAC,IAAAE,QAAA,GAEazC,oBAAoB;AAAA0C,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
package/package.json
CHANGED
package/sdkVersion.js
CHANGED
package/sdkVersion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkVersion.js","names":["version","exports","default","_default"],"sources":["../../../packages/nextjs/src/sdkVersion.ts"],"sourcesContent":["export default { version: '8.0.
|
|
1
|
+
{"version":3,"file":"sdkVersion.js","names":["version","exports","default","_default"],"sources":["../../../packages/nextjs/src/sdkVersion.ts"],"sourcesContent":["export default { version: '8.0.9-alpha.7086267916' };\n"],"mappings":";;;;;;eAAe;EAAEA,OAAO,EAAE;AAAyB,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAC,QAAA"}
|