4,672 questions
1
vote
2
answers
1k
views
How to write SvelteKit middleware or interceptor for fetch both on server and client?
As title says, how to you write middleware in SvelteKit? I know to do it in hooks.server.ts.
I succeed to intercept server requests, but it would be ideal to make interceptor or middleware for both ...
0
votes
1
answer
487
views
TypeScript Error with Prisma Client and withAccelerate Extension in Hono Middleware
I'm working on a Hono application using Prisma and the withAccelerate extension. I'm encountering a TypeScript error when trying to set the extended Prisma client in the context. Here is my code:
...
1
vote
0
answers
91
views
Unable to get JWT decoded token in PHP Slim 4 middleware
I'm developping an API with PHP Slim 4 with JWT authentication. I want to log every request in AWS CloudWatch.
It works, but I want to add in AWS CloudWatch a part of JWT decoded token.
I use tuupola/...
5
votes
1
answer
1k
views
Middleware cannot be used with "output: export"
My files are as follows. I have been trying for several days with more than a thousand combinations but I always get the same result.
Middleware.js:
import { NextResponse } from "next/server&...
-2
votes
1
answer
505
views
Registering Laravel Middleware without make it global [closed]
I'm new in laravel and I confused to how can I register middleware without making it global. in the documentation I only found it to be registered like this (bootstrap\app.php):
this resulting every ...
1
vote
1
answer
71
views
Confused About Middleware in Node.js Express [duplicate]
I'm learning Express.js and I'm a bit confused about the difference between middleware functions and route handlers. I understand that middleware functions usually have the next argument, but I'm not ...
1
vote
2
answers
2k
views
Set Request Cookie in NextJS v14 Middleware
I want to set/update a cookie on the incoming request in the middleware file before the page or layout reads the cookie, but it seems to not be working. Maybe it's not possible..
I made a demo project ...
1
vote
1
answer
506
views
How to redirect an exception that was caught by a middleware back to a controller's action method in C# ASP.NET Core?
Lately, I have been trying to implement a strategy for dealing with exceptions in my C# ASP.NET Core application with no success.
This strategy is structured in two parts:
The first is to have a piece ...
0
votes
1
answer
831
views
How to fix Service trait error when using from_fn_with_state for middleware?
I'm creating a middleware function that authenticates the incoming request. I've read the docs for Axum and some other examples. I'm stuck on a compiler trait error.
Here is the slimmed down code:
#[...
0
votes
0
answers
275
views
Nextjs middleware return null authorization bearer token
In my application I'm sending Authorization bearer token
in middleware I need to get the Authorization but it always coming null
Below are the codes
page.tsx
"use client";
import { useMemo }...
1
vote
2
answers
2k
views
Laravel 11 Middleware route group api doesnt work
I have a api project with Laravel 11, and i want to make a middleware for admin api.
AdminMiddleware.php (custom middleware)
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\...
5
votes
1
answer
3k
views
Firebase Auth Next.JS with middleware
Hello dev friends over there.
I faced an issue with Firebase authentication in Next(TypeScript).
I want to control with middleware about something like permission access.
But, When I use the auth....
1
vote
0
answers
208
views
[NotAuthorizedException: Unauthenticated access is not supported for this identity pool.]
I am getting the error [NotAuthorizedException: Unauthenticated access is not supported for this identity pool.]
I am using Next Js 14.2 version. We are using Amplify v6 gen 1 and I am trying to get ...
0
votes
2
answers
511
views
Next middleware doesn't pass cookies returned from server
I have a Django backend that returns an httpOnly cookie on successful login. This cookie is required for accessing protected routes in the Next app. I have a middleware that checks if a protected ...
1
vote
0
answers
74
views
Passing data from the Clerk middleware to page in Next.js
I'm looking a way to pass data from the clerk middleware to the page (or auth object). I couldn't find anything yet.
export default clerkMiddleware(async (auth, req) => {
const { userId } = auth()...
-1
votes
1
answer
47
views
Intercepting middleware using RTK Query not working
I am trying to add middleware to my apiSlice to console.log something on each and every request, however I do not see any logs (the whole thing works, I just don't see any logs).
apiSlice
const ...
0
votes
1
answer
845
views
How can I match dynamic routes in NextJS middleware functions?
I'm trying to make NextJS middleware mark dynamic routea under /dashboard/[user] as protected thereby performing auth checks when navigating to and from such route. However, I have been unable to do ...
0
votes
1
answer
47
views
Store type of interface and class inhereting the interface as object for later use
I'm trying to create a class where I can pass in an interface and the class which inherits the interface. I will later call a method and use the interface and class to register a Transient service. ...
1
vote
0
answers
128
views
Next.js Middleware issue: Not triggering while hiting protected routes
I am using Next.js version 14.1.0, and I have created a file named middleware.js in the src directory. My src folder contains the following subdirectories:
app
common
components
Within the app ...
1
vote
2
answers
658
views
Nuxt 3 middleware redirect based on IP country code not working when deployed to Netlify
I'm trying to forward traffic to a specific slug based on the user's country code after an IP address lookup.
It works perfectly locally but it's not working when I deploy to Netlify.
export default ...
1
vote
0
answers
283
views
Unable to access Response cookies in NextJS middleware
I'm having trouble accessing the cookies of a Response object in NextJS middleware.
From my understanding, when a login is successful at the /api/auth/login endpoint, it sets a cookie on the Response. ...
0
votes
1
answer
1k
views
My IFunctionsWorkerMiddleware on Azure Function isn't invokated
I'm trying to implement a middleware for my Azure Functions type HttpRequest, I'm using the IFunctionsWorkerMiddleware interface in .NET 6:
public class HistoryLogMiddleware : ...
0
votes
0
answers
132
views
How To Try/Catch System Text Json Errors On ASP.NET Middleware
I am presently encountering an issue with catching errors in ASP.NET's JSON serialization middleware. Specifically, with the following code.
var apiEntity = ModelSerializer.ToApi(entity);
...
0
votes
0
answers
210
views
NextJS 14 ( App Router ) authentication middleware
I am struggling to create a simple jwt cookie authentication middleware where what I want is if there is no cookie to redirect to login and if there is to redirect to dashboard route
here is my ...
0
votes
1
answer
445
views
How do I get the original path of route/endpoint in FastAPI? [duplicate]
Using fastapi, I'm struggling with adding "login_required"(or smh) middleware.
(I think middleware is the best idea, and if I dont get normal solution for my problem, I will have to work ...