Coder Social home page Coder Social logo

Comments (7)

hhxsv5 avatar hhxsv5 commented on May 3, 2024 1

OK, I will check it later.

from laravel-s.

gazben avatar gazben commented on May 3, 2024 1

@hhxsv5 Thank you for, looking into this. I ran out of time to fix this issue, but I wrote the meaningful parts above. If I can come up with something I will let you know.

from laravel-s.

gazben avatar gazben commented on May 3, 2024

If anyone has this, the problem is that the Dingo router dispatching is not applied.
My debug messages:

PHP webserver:

production.INFO: DingoServiceProvider@register  
production.INFO: DingoRouter@dispatch--begin  
production.INFO: DingoRouter@routesDispatched:1  
production.INFO: Current route: api/sites  
production.INFO: SiteController@index | Serializer: League\Fractal\Serializer\DataArraySerializer  
production.INFO: DingoRouter@dispatch--end  
production.INFO: DingoRouter@prepareResponse--begin  
production.INFO: DingoHttpResponseFactory@morph  
production.INFO: DingoRouter@prepareResponse--end  

Swoole webserver:

production.INFO: DingoServiceProvider@register  
production.INFO: Current route: api/sites/asd  
production.INFO: SiteController@index | Serializer: League\Fractal\Serializer\DataArraySerializer  

from laravel-s.

gazben avatar gazben commented on May 3, 2024

If you want to re-register the LumenServiceProvider it will get into an infinite loop.
I think the problem is here (but I still don't know how to fix it):


    /**
     * Add the request middleware to the beginning of the middleware stack on the
     * Lumen application instance.
     *
     * @param \ReflectionClass $reflection
     *
     * @return void
     */
    protected function addRequestMiddlewareToBeginning(ReflectionClass $reflection)
    {
        $property = $reflection->getProperty('middleware');
        $property->setAccessible(true);

        $middleware = $property->getValue($this->app);

        array_unshift($middleware, Request::class);

        $property->setValue($this->app, $middleware);
        $property->setAccessible(false);
    }

from laravel-s.

hhxsv5 avatar hhxsv5 commented on May 3, 2024

@gazben Thanks for your feedback, this issue is similar to #28.
So far, I don't have a graceful solution. But I will follow it up.

from laravel-s.

gazben avatar gazben commented on May 3, 2024

The main problem is located the same as in #28 the removeMiddlewareFromApp function in the router adapter is not reset after the first request is served, and will get into the infinite loop because the Request middleware is not removed.

If I just disable the thing:

    protected function removeMiddlewareFromApp()
    {
        if ($this->middlewareRemoved) {
            \Log::info('Middleware already removed!');
            return;
        }

        $this->middlewareRemoved = false; // this is true originally
...

The GET/POST requests will work fine. But the OPTIONS requests are failing with no error message just the 500 status code and no log. So basically the same as #28.
Without logs I'am running out of ideas :(

from laravel-s.

gazben avatar gazben commented on May 3, 2024

@hhxsv5 Can I return a response from a middleware in laravels? The function is called according to the logs, but after it returns, it throws a 500 error.

My cors middleware:

    public function handle(Request $request, Closure $next)
    {
        if($request->isMethod('OPTIONS')) {
            $response = new \Dingo\Api\Http\Response(null);
            $this->setCorsHeaders($request, $response);
            return $response;
        }

        return $next($request);
    }

from laravel-s.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.