@levo-so/next-middleware 0.1.19 → 0.1.43

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/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import { type NextRequest, NextResponse } from "next/server";
5
5
  declare function middleware(request: NextRequest, options?: {
6
6
  apiUrl?: string;
7
7
  insightsUrl?: string;
8
+ isHeadless?: boolean;
8
9
  }): NextResponse<unknown> | undefined;
9
10
  declare const levoConfig: {
10
11
  matcher: string[];
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { NextResponse } from "next/server";
3
3
  * @description This function can be marked `async` if using `await` inside
4
4
  */
5
5
  function middleware(request, options = {}) {
6
- const { apiUrl = "https://public-api.levo.so", insightsUrl = "https://insights-api.levo.so", } = options;
6
+ const { apiUrl = "https://public-api.levo.so", insightsUrl = "https://insights-api.levo.so", isHeadless = false, } = options;
7
7
  const { nextUrl } = request;
8
8
  const { pathname, search, hash } = nextUrl;
9
9
  const host = request.headers.get("host");
@@ -39,8 +39,9 @@ function middleware(request, options = {}) {
39
39
  * Since NextJS can serve file types other than `text/html`, we have to specifically reverse proxy
40
40
  * file-based path to the backend server directly, which serves the file, if found in appropriate filetypes
41
41
  * such as `text/plain` for `robots.txt` and `application/xml` for sitemaps
42
+ *
42
43
  */
43
- if (request.nextUrl.pathname.endsWith("robots.txt") ||
44
+ if ((!isHeadless && request.nextUrl.pathname.endsWith("robots.txt")) ||
44
45
  // check if it is a sitemap xml, can be `sitemap-static.xml`, `sitemap_index.xml` or other sitemap xml files
45
46
  (request.nextUrl.pathname.includes("sitemap") &&
46
47
  request.nextUrl.pathname.endsWith(".xml"))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/next-middleware",
3
- "version": "0.1.19",
3
+ "version": "0.1.43",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Next middleware to add a proxy for levo integration in apps",
6
6
  "type": "module",