Giter Site home page Giter Site logo

Comments (11)

mevdschee avatar mevdschee commented on May 8, 2024 1

Update: Reading an extensive mozilla article on the subject. I will implement a fix.

from php-crud-api.

mevdschee avatar mevdschee commented on May 8, 2024 1

Request header field Content-Type is not allowed by Access-Control-Allow-Headers.

I fixed this one in b4051e9 by adding: Access-Control-Allow-Headers: Content-Type

Can you try again? I would like it to work without the Chrome CORS extension.

from php-crud-api.

mevdschee avatar mevdschee commented on May 8, 2024

small detail (probably not the issue): "99" has a trailing comma

from php-crud-api.

mevdschee avatar mevdschee commented on May 8, 2024

I think the problem is with the options request, let me test it locally. Hang on..

from php-crud-api.

mevdschee avatar mevdschee commented on May 8, 2024

Update: I confirmed it is the "pre-flight" or "options" request that gives a 404.

from php-crud-api.

mevdschee avatar mevdschee commented on May 8, 2024

Update: Should be fixed in 54e312f

from php-crud-api.

mevdschee avatar mevdschee commented on May 8, 2024

Please let me know whether or not it works for you.

from php-crud-api.

0noel0 avatar 0noel0 commented on May 8, 2024

It works great !!!, thank you very much. you saved me.

Just something for documentation, you must use an extension for CORS or add the header "header ('Access-Control-Allow-Origin: *');" api.php in the file to allow make the request.

Thanks again for your time, keep it up !!!
Noob developers appreciate this help !!!

from php-crud-api.

mevdschee avatar mevdschee commented on May 8, 2024

@0noel0 Does the latest version still need the extra "header('Access-Control-Allow-Origin: *');" call? That should not be necessary. Please let me know.

from php-crud-api.

0noel0 avatar 0noel0 commented on May 8, 2024

I had not really tested the effect of the header, it does not affect whether or not it gets, but the extension of CORS if necessary.

This is the error in console without the extension:

XMLHttpRequest cannot load http://localhost/mysql-crud-api/api.php/cap/1/. Request header field Content-Type is not allowed by Access-Control-Allow-Headers.

I use the CORS (Chrome extension)
URL:https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?utm_source=gmail

And to enable this extension does not return the error appears.
Only return 1 (Success).

But as far as if this is not an error.

from php-crud-api.

mevdschee avatar mevdschee commented on May 8, 2024

Added an AngularJS example in d69fa4d

from php-crud-api.

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.