Code Monkey home page Code Monkey logo

php-cors's Issues

PHP 8.1.3 can't install composer

Hi. I have PHP version 8.1.3.
We have an error for updating Laravel to version 9

Root composer.json requires fruitcake/laravel-cors ^1.2.0, found fruitcake/laravel-cors
[dev-feat-lazyoptions, dev-feat-groupmiddleware, dev-test-single, dev-feat-middlewaretest, 
dev-feat-actions, dev-feat-browsertests, dev-master, dev-v1-backport, dev-feat-prependmiddleware, 
dev-develop, dev-barryvdh-test-laravel9, 
v0.1, ..., 0.11.x-dev, v1.0.0, ..., 1.0.x-dev, v2.0.0-beta1, ..., 2.2.x-dev, v3.0.0, 3.0.x-dev 
(alias of dev-master)] 
but it does not match the constraint.

Documentation is not goood

Steps needed to make it work (on Lumen only)

  • copy cors.php to config\cors.php
  • Then on bootstrap\app.php enable configuration, add this line $app->configure('cors');
  • (in my case, I was in question why the cors value is empty)
  • Then add this line \Illuminate\Http\Middleware\HandleCors::class to $app->middleware
  • Once that done. If you have custom header such as in my case x-api-key you must add it to allowed_headers array example: ['x-api-key']
  • Then on your api call such as axios you can add it to your custom headers which is base on this documentation Doc
  • Note that the X-Auth-Token should be pass as x-auth-token as I check, the server returns it as small cases.

How to CORS in Lumen

Hello I switched to Lumen 9.1.6. I had composer saying that laravel-cors has to be replaced. Currently, I have in app.php :

<?php

$app->configure('cors');

$app->middleware([
    Fruitcake\Cors\HandleCors::class,
]);

$app->register(Fruitcake\Cors\CorsServiceProvider::class);

I have replaced \Fruitcake\Cors\HandleCors::class, with \Illuminate\Http\Middleware\HandleCors::class but what about the service provider ?

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.