Socket
Book a DemoInstallSign in
Socket

github.com/gofiber/cors

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/gofiber/cors

v0.2.2
Source
Go
Version published
Created
Source

CORS

Release Discord Test Security Linter

Install

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

config

PropertyTypeDescriptionDefault
Filterfunc(*Ctx) boolDefines a function to skip middlewarenil
AllowOrigins[]stringAllowOrigin defines a list of origins that may access the resource.[]string{"*"}
AllowMethods[]stringAllowMethods 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"}
AllowCredentialsboolAllowCredentials 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[]stringExposeHeaders defines a whitelist headers that clients are allowed to access.[]string{}
MaxAgeintMaxAge 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

FAQs

Package last updated on 23 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.