Skip to content

Instantly share code, notes, and snippets.

@TuenTuenna
Last active October 28, 2023 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TuenTuenna/cd96f76f5f9d6206ac169e81354fdbd7 to your computer and use it in GitHub Desktop.
Save TuenTuenna/cd96f76f5f9d6206ac169e81354fdbd7 to your computer and use it in GitHub Desktop.
next.config.js 파일 -> cors 세팅
/** @type {import('next').NextConfig} */
const nextConfig = {
    async headers() {
        return [
            {
                // matching all API routes
                source: "/api/:path*",
                headers: [
                    { key: "Access-Control-Allow-Credentials", value: "true" },
                    { key: "Access-Control-Allow-Origin", value: "*" }, // replace this your actual origin
                    { key: "Access-Control-Allow-Methods", value: "GET,DELETE,PATCH,POST,PUT" },
                    { key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" },
                ]
            }
        ]
    }
}

module.exports = nextConfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment