Giter Site home page Giter Site logo

post will CORS about fastify-cors HOT 6 CLOSED

fastify avatar fastify commented on May 20, 2024
post will CORS

from fastify-cors.

Comments (6)

mcollina avatar mcollina commented on May 20, 2024

Can you please upload a full example and clear instructions on how to reproduce?

from fastify-cors.

l02162010 avatar l02162010 commented on May 20, 2024

@mcollina ok
it is frontend
it is backend
my problem is when post not follow Schema will cors
but follow Schema everything will be fine
I want to know how to let post don't cors and response Schema error like
{
"statusCode": 400,
"error": "Bad Request",
"message": "body should have required property 'confirmPwd'"
}

from fastify-cors.

mcollina avatar mcollina commented on May 20, 2024

I need full instructions to reproduce:

  1. do this...
  2. do that...

from fastify-cors.

l02162010 avatar l02162010 commented on May 20, 2024
  1. git clone frontEnd & backEnd , and npm install
  2. use npm run dev to run frontEnd & backEnd
  3. open http://localhost:3000/login
  4. you will see the form, please input something and send
  5. console will say cors problem
  6. use editor open frontEnd
  7. find /pages/login.vue in frontEnd folder
  8. confirmPwd: this.form.confirmPwd open this
  9. send register again on http://localhost:3000/login
  10. you will find it fine.

the step 5 , how to make it response like this
{ "statusCode": 400, "error": "Bad Request", "message": "body should have required property 'confirmPwd'" }

from fastify-cors.

mcollina avatar mcollina commented on May 20, 2024

The error you are experiencing is totally normal. Basically you'll need to either:

a. serve your Nuxt app from within fastify itself
b. disable cors in development, so that it does not error
c. configure cors so that localhost:4000 is allowed to send a request to localhost:3000

from fastify-cors.

l02162010 avatar l02162010 commented on May 20, 2024

I use this solve my problem, thank you.

from fastify-cors.

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.