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

How to use it in nextjs middleware? #20

Open
mnsrulz opened this issue Nov 26, 2024 · 1 comment
Open

How to use it in nextjs middleware? #20

mnsrulz opened this issue Nov 26, 2024 · 1 comment

Comments

@mnsrulz
Copy link

mnsrulz commented Nov 26, 2024

With very minimal configuration as shown below, it's running fine when running in local, but when it's getting deployed in netlify platform which uses edge runtime for middleware, it's erroring out.

import { log } from '@logtail/next'

export default auth((req) => {
       log.info(`${req.method} ${req.nextUrl.pathname}`, { path: req.nextUrl.pathname, method: req.method });
})

export const config = {
       matcher: ['/((?!api/auth|_next/static|_next/image|.*\\.png$|.*\\.ico$).*)']
};

Error

error  TypeError: Invalid URL: '/_logtail'
    at getSerialization (ext:deno_url/00_url.js:98:11)
    at new URL (ext:deno_url/00_url.js:405:27)
    at new Request (ext:deno_fetch/23_request.js:329:25)
    at ext:deno_fetch/26_fetch.js:319:27
    at new Promise (<anonymous>)
    at fetch (ext:deno_fetch/26_fetch.js:315:18)
    at file:///root/src/bootstrap/util/fetch.ts:110:14
    at e.<anonymous> (file:///root/.netlify/edge-functions/___netlify-edge-handler-src-middleware/server/src/middleware.js:417:66924)
    at file:///root/.netlify/edge-functions/___netlify-edge-handler-src-middleware/server/src/middleware.js:417:63725
    at Object.next (file:///root/.netlify/edge-functions/___netlify-edge-handler-src-middleware/server/src/middleware.js:417:63830)
@curusarn
Copy link
Contributor

Hi @mnsrulz!

Thank you for your patience. I appreciate it.
I'm passing this on to a dev team so they can reproduce and fix the issue.

We'll update you here is GitHub once there are any updates.

Thank you for raising this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants