Code Monkey home page Code Monkey logo

cors's Introduction

CORS

Release Discord Test Security Linter

Install

go get -u github.com/gofiber/fiber
go get -u github.com/gofiber/cors

config

Property Type Description Default
Filter func(*Ctx) bool Defines a function to skip middleware nil
AllowOrigins []string AllowOrigin defines a list of origins that may access the resource. []string{"*"}
AllowMethods []string AllowMethods defines a list methods allowed when accessing the resource. This is used in response to a preflight request. []string{"GET", "POST", "HEAD", "PUT", "DELETE", "PATCH"}
AllowCredentials bool AllowCredentials indicates whether or not the response to the request can be exposed when the credentials flag is true. When used as part of a response to a preflight request, this indicates whether or not the actual request can be made using credentials. false
ExposeHeaders []string ExposeHeaders defines a whitelist headers that clients are allowed to access. []string{}
MaxAge int MaxAge indicates how long (in seconds) the results of a preflight request can be cached. 0

Example

package main

import (
  "github.com/gofiber/fiber"
  "github.com/gofiber/cors"
)

func main() {
  app := fiber.New()

  app.Use(cors.New())

  app.Get("/", func(c *fiber.Ctx) {
    c.Send("Welcome!")
  }) 

  app.Listen(3000)
}

Test

curl -H "Origin: http://example.com" --verbose http://localhost:3000

cors's People

Contributors

fenny avatar pot-code avatar

Watchers

 avatar

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.