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
12
votes
6 answers

Adding 'SameSite=None;' cookies to Rails via Rack middleware?

On February 4th 2020, Google Chrome will require SameSite=None; to be added to all cross-site cookies. Rails 6.1 and soon Rails 6.0 have added a same_site: :none option to the rails cookie hash: cookies["foo"]= { value: "bar", expires:…
Kelsey Hannan
  • 2,857
  • 2
  • 30
  • 46
12
votes
4 answers

Proxied requests other than GET are hanging with NestJS and http-proxy-middleware

Example code is available on https://github.com/baumgarb/reverse-proxy-demo The README.md explains how you can re-produce the issue if you clone the repo. I have an API Gateway and a downstream service which returns todos (TodosAPI). A client goes…
baumgarb
  • 1,955
  • 3
  • 19
  • 30
12
votes
5 answers

MVC authorization inside MapWhen() is applied to all controllers

In ASP.Net Core 3.0 Preview 7, I tried to write some code as follows: public void Configure(IApplicationBuilder app) { app.MapWhen(context => context.Request.Path.StartsWithSegments( new PathString("/UnsecureLog")), …
Wellspring
  • 1,128
  • 1
  • 10
  • 19
12
votes
5 answers

How to set in a middleware a variable accessible in all my application?

I am using Ruby on Rails 3 and I am trying to use middlewares in order to set a variable @variable_name accessible later in controllers. For example my middleware is class Auth def initialize(app) @app = app end def call(env) …
user502052
  • 14,803
  • 30
  • 109
  • 188
12
votes
4 answers

How can I combine Go middleware pattern with error returning request handlers?

I am familiar with the Go middleware pattern like this: // Pattern for writing HTTP middleware. func middlewareHandler(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Our…
Alex
  • 5,671
  • 9
  • 41
  • 81
12
votes
3 answers

asp.net core remove X-Powered-By cannot be done in middleware

Why can I not remove X-Powered-By as part of my middleware that I am executing? I can remove it if I put in the web.config but not if I put it in the middleware. I am removing another header in the middleware "Server" : "Kestrel" which works and…
Jamie Hollyhomes
  • 141
  • 1
  • 1
  • 5
12
votes
2 answers

How do I set a cookie with a (ruby) rack middleware component?

I'm writing a rack middleware component for a rails app that will need to conditionally set cookies. I am currently trying to figure out to set cookies. From googling around it seems like this should work: class RackApp def initialize(app) …
phaedryx
  • 2,024
  • 3
  • 16
  • 24
12
votes
3 answers

exit from express middleware with specific http status

Hopefully this is a simple one, but I have some custom middleware which I want to return a 404 or 401 etc to the user and stop the propagation of other handlers etc. I was expecting I could do something like: function SomeMiddleware(req, res, next)…
Grofit
  • 17,693
  • 24
  • 96
  • 176
12
votes
3 answers

exit from chain of route specific middleware in express/ nodejs

I have a chain of "route specific middleware" for this route, like so: var express = require('express'); var server = express(); var mw1 = function(req, resp, next) { //do stuff if (success) { next(); …
bguiz
  • 27,371
  • 47
  • 154
  • 243
12
votes
3 answers

Express Req.Body Validation

I want to create a piece of express middleware looks something like this: function validate (options) { var defaultOptions = {...} , validations = _.extend(defaultOptions, options); return validate (req, res, next) { /* Use some sort of…
arb
  • 7,753
  • 7
  • 31
  • 66
12
votes
1 answer

flask: wsgi-middleware vs before_ and after_request()

I find it quite confusing what exactly are the differences in using Flask's before_request() and/or after_request() versus using a WSGI middleware. Say I want to do something very silly like this: Every request-body should be scanned for the word…
bmaeser
  • 982
  • 7
  • 13
11
votes
2 answers

Why am I getting this error when using Next.js middleware?

The Problem I'm using Next.js, Prisma, and NextAuth's Email Provider strategy to setup an authentication system. I want to use Next.js middleware to redirect a request if it doesn't contain a valid session. But any use of the middleware, like…
rolias4031
  • 233
  • 2
  • 10
11
votes
5 answers

Uncaught SyntaxError: expected expression, got '<' while using Next.js middleware

I'm using Next.js middleware to redirect to the login page if there's no available token using Spotify's API, My middleware looks like this: import { getToken } from "next-auth/jwt"; import { NextResponse } from "next/server"; import type {…
Mohamed Nabil
  • 525
  • 2
  • 9
  • 24
11
votes
3 answers

Custom middleware (or authorize) for specific route in ASP .NET Core 3.1 MVC

In my ASP .NET Core 3.1 MVC app, I use endpoint routing like so app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern:…
user2768479
  • 716
  • 1
  • 10
  • 25
11
votes
1 answer

what are java middleware technologies

What technologies can we name as 'Java Middleware'? If I say JMS, WS is that correct?
user668943
  • 535
  • 1
  • 5
  • 8