Questions tagged [middleware]

Middleware is computer software that provides services to software applications beyond those available from the operating system. It can be described as "software glue".

Middleware is a software component (or components) that sits "in the middle" between applications and the operating system. Typically, middleware will facilitate application development by providing services such as communications, file access, or thread locking that have a common Application Programming Interface (API) across multiple operating systems.

Communications Middleware is a specific kind of middleware that allows for interprocess communications (on one machine or across a network). The purpose of Communications Middleware is to simplify the designing, programming, and managing of software applications by streamlining the way these applications receive and process data. Communications Middleware simplifies writing communications software while providing sophisticated built-in features, reducing development costs.

Examples of communications middleware include:

4333 questions
1
vote
1 answer

The input does not contain any JSON tokens

I am getting below error due to my middleware The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0. Below is my…
Saurabh
  • 1,505
  • 6
  • 20
  • 37
1
vote
1 answer

If write the URL of the web I can access the data from API, but when If I fetch in getServerSideProps it cannot get the session in Next.js (nextAuth)

If API is accessed as GET request from the browser as authenticated, you get the data. But when you want to access the data by fetching in client-side by the function getserverside gives me the error that is not authenticated which it fact it…
n9p4
  • 304
  • 8
  • 34
1
vote
1 answer

Next.js middleware to set Axios header

I'm trying to use Next 12 to add an Authorization header to my Axios instance with middleware. However, it doesn't look as though the header is actually being passed into the requests within getServerSideProps, and I can't figure out why. This is…
Jesse Winton
  • 568
  • 10
  • 33
1
vote
1 answer

Next.js middleware always return null as body

Request has a body property, but it seems to always be null for me in middleware functions. If reading the body is not supported in middleware it would be nice for the docs to note that, and maybe for NextRequest to throw a helpful error when the…
Chukwuemeka Maduekwe
  • 6,687
  • 5
  • 44
  • 67
1
vote
0 answers

.net core 6: execute middleware on a route

I am using .net core 6 and from the below image, I saw that the middlewares are executed before routing: But you have the possibility to execute a middleware for a certain route, like in this extension method: public static…
Buda Gavril
  • 21,409
  • 40
  • 127
  • 196
1
vote
2 answers

How do i handle Errors in node express app?

Is there a way to add middleware or app.use() to catch all possible errors? I have tried some global try-catch approaches but it looks so fragile.
bhaRATh
  • 716
  • 4
  • 23
1
vote
1 answer

How to add custom middleware in asp.net core with identity server 4 between authentication and authorization?

I need to add custom middleware between authentication and authorization that will add ClaimsIdentity to User that in context. public class PermissionsMiddleware { private readonly RequestDelegate _next; public…
kin9sl4yer
  • 13
  • 2
1
vote
1 answer

How Not To Authenticate Specific User Using Sanctum Laravel

I'm trying to write web services in Laravel that are protected by auth:sanctum, but I want it not to be protected in case of a specific user logged in. User with these credentials: telephone: 0900 000 00 00 password:…
1
vote
1 answer

laravel middleware with parameter in route executed twice

I have this very simple middleware namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; class CacheResponseMinify { /** * Handle an incoming request. …
1
vote
1 answer

How to get data from api routes in next js

Hi i am having api routes which listens to incoming request , Code looks something like this async function handler(req, res) { // Run the middleware await runMiddleware(req, res, cors) // Rest of the API logic res.json({ message: 'Hello Everyone!'…
NoobCoder
  • 45
  • 1
  • 6
1
vote
1 answer

Pass argument down to next handle func from middleware

I would like to make a reusable middleware for validation throughout my API. Here, validation is done through govalidator, so I just need to pass the validation rules and a DTO where the request is mapped into. func ValidationMiddleware(next…
Jeremy
  • 1,447
  • 20
  • 40
1
vote
1 answer

How can I use express-rate-limit in sailsJS?

I want to use a express-rate-limit middleware in sailsJS framework for preventing brute force attacks/ adding attempts for logging in. The documentation shows the implementation for basic nodejs but how can we add that logic in sailsjs framework. I…
1
vote
0 answers

Chaining queries in mongoose

Please check the below mongoose code in nodejs. reviewSchema.pre(/^findOneAnd/, async function(next) { this.review = await this.findOne(); next(); }); reviewSchema.post(/^findOneAnd/, async function(next) { await…
Manishpant
  • 37
  • 1
  • 5
1
vote
2 answers

How to configure Middleware to Blazor app

I there, I've a Blazor app here that I would like to add Middleware class to it. but I can't find the startup.cs/IApplicationBuilder to add it. My project only have a Program.cs class with a void Main method. So how to configure a Middleware? Just…
Hugo
  • 2,077
  • 2
  • 28
  • 34
1
vote
1 answer

.Net 6 Middleware Request Path

As off .Net 6, a middleware containing context.Request.Path = "/error/500" no longer rewrites the new path to handle the exception. Is there a new way to set a request path in .Net 6 within the middleware? Thank you! Attached is an example code: …
Chris
  • 336
  • 4
  • 15