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".
3,758
questions
0
votes
0
answers
19
views
redux toolkit doesn't seem to work with redux-loop
I am starting a react-native application in which I am trying to configure @reduxjs/toolkit with redux-loop using configureStore's middleware option. But when I run the build it crashes with error u....
0
votes
0
answers
14
views
Unable to route to a path using router.route()
I recently started working on a project I create a route and while I am trying to trigger it using a postman request it just gives the following result in postman.
The request that I am sending
I ...
0
votes
1
answer
29
views
Access to update the user/middleware
I have a simple put method to update the user and i added a middleware(Auth) to check the user is login or not but i have a problem that Any logged in user can update another users.
I want each user ...
0
votes
2
answers
39
views
Two different login system in Laravel 9
In my case, I will create a login system with two different users. a) Voters and b) Administrators. Where "Voters" login using the ID Number and password. That password generated by the ...
0
votes
1
answer
40
views
NextJS 12 middleware veify JWT token prolem
I'm trying to use JWT verification for authentication with middleware, but unfortunately, I'm getting some errors that cannot find a solution for.
./node_modules/jwa/index.js:3:0
Module not found: Can'...
-4
votes
0
answers
20
views
Why my route is not recognizing my middleware as a parameter? [closed]
I am trying to use a middleware to validate a token with JWT with the function checkToken, but i'm getting the error:
"ReferenceError: checkToken is not defined."
Someone can help me about ...
0
votes
0
answers
18
views
Do all NextJS features work when dockerized and deployed to Cloud run?
Lets say for example I have a NextJS app with _middleware and getServerSideProps and getStaticProps and I want to use it on Cloud Run.
First using Docker I'll make an Image after that I upload it to a ...
0
votes
0
answers
25
views
How to get name of requested controller and method name in middleware only, not in contoller
I read this:
How to get name of requested controller and action in middleware Laravel
But it doesn't work in middleware in Laravel 9.
Here is code web.php:
Route::get('/debug',"App\Http\...
0
votes
0
answers
25
views
How to fetch data from fixed length .Dat file in SOA?
I have a requirement in SOA to Read/Write fixed length file from source/destination by applying condition on each line, below are the sample of .dat fixed file.
165 5454 abc
333test file
45466 ...
1
vote
0
answers
19
views
Does prometheus golang (echo-contrib) exporter saves metrics in memory?
I have a GoLang middleware for exporting metrics for prometheus, which are then served from /metrics endpoint
My question is where does the data received from /metrics endpoint come from?
Does it come ...
0
votes
0
answers
40
views
Laravel 9.x - Class binding not working in middleware
i am having issue in my laravel middleware.
i try to extends Illuminate\Http\Request to my custom class request
<?php
namespace LaravelCommon\Http\Request;
use App\Repositories\User\...
0
votes
0
answers
28
views
function can() on null --- function isAdmin() on null
I am trying to create a forum but when I go to the main page it shows me the following message:
Call to a member function isAdmin() on null
or
Call to a member function can() on null
IsAdmin.php (this ...
2
votes
1
answer
29
views
userData.name is not showing the user's name
I am learning MERN and I created a simple website on which you can log in and register.
The login and register functionality is working perfectly but my About page has some errors.
The about page ...
0
votes
1
answer
43
views
How can I use multiple middlewares on the same route name in Laravel 9?
I want my /dashboard page to be a different panel in 2 different user types. And return to home screen if not logged in. I created 2 middlewares to check if logged in user is "employer" or &...
0
votes
2
answers
28
views
usage of cors middleware vs custom middleware
Pardon me for this stupid question, but can someone explain me how the cors middleware work?
I accidentally called an auth middleware by adding brackets after it and it ran that middleware without ...
0
votes
0
answers
13
views
Nexjs middleware keeps routing even after I have stopped hosting the site and cleared cookies
I have 2 sites which periodically share the localhost:3000. One of them uses the middleware to route to a different URL. Problem is when i stop hosting that site and start the other one (without the ...
0
votes
0
answers
24
views
From NodeJS middleware to PHP middleware for VueJs SPA
I have no idea on how to convert a very simple middleware NodeJS to PHP.
To make it simple, I already have an API I call to login to my app, and currently use the below middleware to get a JWT in ...
0
votes
0
answers
15
views
How does fix this Warning: DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE
How does fix this Warning: DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE
in simple Create React App and when I don't use Webpack
-2
votes
1
answer
45
views
How Can I detect when browser is closed and change user status in database in laravel 8? How can I do that I [closed]
I have created the user status lastActivityUser.php but i want functionality that whenever a user closes the browser the user status is set to offline maybe based on session expiry or anyway. How can ...
0
votes
1
answer
20
views
How to encrypt adonis js 5 response data using middleware
I want to encrypt data sent from adonis js 5 response using middleware.
I am returning response data from my service class api to react front end in this way:
public async login(username:string,...
0
votes
1
answer
21
views
having error with getdefaultmiddleware of redux toolkit in adding logger conditionally
Solved!
const config =
process.env.NODE_ENV == "development"
? {
reducer: persistedReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
...
1
vote
1
answer
18
views
Does gorilla mux subrouters inherit the middlewares of their parent router?
The whole question is in the title.
I was searching on SO if a subrouter will use a middleware of its parent, in the case the middleware is applied to the parent router with the method Use(), but I ...
0
votes
1
answer
31
views
Swashbuckle blocked by middleware authentication
I'm creating a minimal API in dotnet 6. I have the default implementation of Swagger/Swashbuckle and everything was fine until I added a simple, custom authentication middleware (see code below).
The ...
0
votes
3
answers
61
views
Difference between middleware chi.Use vs chi.With
What is the difference between chi.Use and chi.With when setting up a middleware with Chi router.
0
votes
1
answer
43
views
How to add different middleware to routes under same sub route in gofiber
I have a route configuration as below with a base route and 5 subroutes under that
baseRoute := app.Group("/base")
baseRoute.Post("/sub_route1", handler1)
baseRoute.Post("/...
0
votes
0
answers
14
views
Nestjs: Access remote api from a middleware
I want to perform a fetch call in order to validate data that comes from the header HTTP call. the data validation happens in a remote server and should check if the user_id that I send exists in the ...
0
votes
2
answers
25
views
How to use mongoose.isValidObjectId as a middleware in nestjs?
I have an issue with repetitive requests for checking an Order id, if it is valid ObjectId or not. I got this error:
CastError: Cast to ObjectId failed for value "629b9fbd620dbc419a52e8" (...
1
vote
1
answer
91
views
next.js middleware, NextResponse.redirect() not working when using map or foreach, but it works when using for loops
//this won't work
rules.filter(rule => rule.type === 'redirect' && new RegExp(rule.rule).exec(pathname.slice(1)))
.map(rule => {
console.log('match');
const url = ...
0
votes
0
answers
19
views
Is it a good practice to modify the request body in a middleware?
Hello guys I have a question about middlewares.
I have an API with two constraints:
Checking if the access token is valid
Checking if the user is admin
I have to check if the access token is valid ...
0
votes
0
answers
19
views
How can I deal with this "Actions must be plain objects. Use custom middleware for async actions" without createStore()?
I am getting the below error on API calls. It seems I have not correctly configured the store.
Error:
Actions must be plain objects. Use custom middleware for async
actions.
The below files might be ...
0
votes
1
answer
60
views
Next.js fails to build due to Dynamic Code Evaluation not allowed in Middleware
My Next.js project started failing to compile in build time once i introduced Next-auth dependency to handle social-login within providers (google) and credential login using email/password.
here's ...
0
votes
0
answers
42
views
How do I give a non-admin user permission to post certain data in NodeJS?
In my nodejs app, I have several tables, such as bus-table, location-table, trip-table, and booking-table.
Some, such as bus, trip, and location, are only accessible to administrators.
And one table ...
-1
votes
0
answers
19
views
Get protected API data in Laravel/Jetstream via AXIOS
I have a problem with pass the data under protected (by Middleware) API route. When I send the request I have information "Unauthenticated".
I read that I have to generate Bearer Token and ...
1
vote
1
answer
20
views
Why do we add properties to request object?
I can't understand why do we add properties to request object?
As I know, the request object comes from the front end side and if any information is needed or they have, the frontend side should ...
1
vote
2
answers
32
views
Express router, Router.post executing before router.use middleware
My problem is that for some reason express router doesn't wait for next() function inside middleware and goes str8 to execution fo router.post.
Router.use('/posts/add', addPosts);
Router.post('/posts/...
0
votes
1
answer
26
views
How to perform an api call from a middleware in express - NodeJS
First of all, I'm working with express in NodeJS.
I want to create an API call for updating the user's personal account informations.
Before doing this I should ask the user for the password for more ...
0
votes
0
answers
36
views
Express.js, res.redirect doesn't work after express.static?
I don't know why the redirect from a middleware doesn't work after an express.static.
I want to go to /login when I reload the page /ok. This is my code:
app.use('/ok', express.static('public'));
...
0
votes
1
answer
25
views
Express middleware to conditionally change response result
What I want to achieve is when an express handler fails either by throwing an unhandled exception or returning an empty response like undefined or [], I want the handler to return a predefined mock ...
0
votes
1
answer
49
views
Same route different middleware route group
Here is my super admin middleware,
if(Auth::user()->role_id == 1) {
return $next($request);
}
return redirect('/');
and,here is admin middleware,
if(Auth::user()->role_id == 2) {
return ...
1
vote
0
answers
14
views
express-openid-connect added routes (/login /logout) fail (not found 404)
Same app. /login fails (route not found) with this code:
app.use(/^(?!\/api).+/,
auth({
auth0Logout: true,
issuerBaseURL: process.env.ISSUER_BASE_URL,
baseURL: process.env....
-1
votes
1
answer
57
views
How to intercept the response of a request to an endpoint in NodeJs (Express 4) before it goes out
I am working on a NODE JS project with Typescript started by other people and I need to trigger an action if the response from some endpoints is successful, so I need to intercept this response before ...
0
votes
0
answers
19
views
csurf token - invalid token on web application (Works in postman)
My csrf token keeps returning invalid on my post request inside my application, but works in postman. Any idea of why it won't work on the browser? I'm using jquery and have a nodejs/express server. I'...
0
votes
0
answers
26
views
Limit on number of Express Application MIddleware?
We use an express backend and we recently ran into a strange bug when adding a new middleware to one of our routes. We have been binding the handlers to the route as follows:
app.all('/route', [...
0
votes
0
answers
23
views
Rails Middleware class not defined
I have created a little middleware app for tracking Mailgun events , in lib/middleware of a rails app, and 2 files, one for the Mailgun Tracking env details and one as a class MailLogger which has the ...
0
votes
0
answers
14
views
Can I disable the creation of _middlewareManifest.js in NextJS?
I am not using any middleware in NextJS but yet there still is a _middlewareManifest.js with self.__MIDDLEWARE_MANIFEST=[];self.__MIDDLEWARE_MANIFEST_CB&&self.__MIDDLEWARE_MANIFEST_CB() in it.
...
0
votes
0
answers
27
views
Express req.body is empty based on middlewear placement in callback list
Heads up, i'm relatively new to node, express so it might be a simple answer but i don't understand why one middle-wear works and the other doesn't.
//Function i'm trying to use as middle-wear
const ...
-1
votes
1
answer
89
views
Express Session Middleware
I am doing the Coursera course on Server-Side Development and I have followed the instructions precisely. I keep getting this error, however. There are no relevant posts on their Discussion platform,...
0
votes
1
answer
32
views
How can i create a logger middleware in express without any package or library
I've trying to create a custom logger middleware without any package or library
It's as simple as saving the endpoint, the method and the status code response.
I have the problem when I try to save ...
0
votes
0
answers
18
views
AppServiceProvider creates problems during import
I have in my AppServiceProvider code, which generates menu from MenuTop model.
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
$topmenu = MenuTop::...
0
votes
0
answers
45
views
How to separate servlet filter in a different application
I have a simple Springboot application which shows example of different restful Api's and i have connected the application with postgresql database.
I made servlet filter as a middleware to capture ...