Giter Club home page Giter Club logo

Comments (1)

bluepebble25 avatar bluepebble25 commented on June 12, 2024

겪은 문제

  • 헤더를 보냈더니 개발자 도구의 네트워크나 Postman에서 봤을때는 헤더가 잘 도착했다. 하지만 클라이언트에서 js 코드로 접근하려고 하니 Content-type이나 Content-type같은 기본적인 헤더밖에 보이지 않는다.

해결방법

CORS 정책때문에 헤더에 접근하는 것에 제한이 걸리므로 클라이언트가 특정 헤더에 접근하는 것을 허용하려면 서버에서 접근 가능한 헤더를 지정해줘야 한다.

app.use(
  cors({
    exposedHeaders: ['X-Total-Count'],
  })
);

참고로 클라이언트에서는 res.headers['X-Total-Count']로 특정 헤더에 접근한다.
헤더를 모두 보려면 res.headers

from phoca-review.

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.