Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/Medzoner/traefik-plugin-cors-preflight

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/Medzoner/traefik-plugin-cors-preflight

  • v1.0.7
  • Source
  • Go
  • Socket score

Version published
Created
Source

Traefik Plugin: CORS Preflight

Build Status Coverage Status License Go report

Short Description

Pass the browser cors preflight with response status 204 for Method OPTIONS

Configuration

Requirements: Traefik >= v2.5.5

Static

--pilot.token=xxx
--experimental.plugins.corspreflight.modulename=github.com/Medzoner/traefik-plugin-cors-preflight
--experimental.plugins.corspreflight.version=v1.0.4
pilot:
  token: xxx

experimental:
  plugins:
    corspreflight:
      modulename: github.com/Medzoner/traefik-plugin-cors-preflight
      version: v1.0.4
[pilot]
    token = "xxx"

[experimental.plugins.corspreflight]
    modulename = "github.com/Medzoner/traefik-plugin-cors-preflight"
    version = "v1.0.4"
testData:
  testData:
    Code: 204
    Method: 'OPTIONS'

Dynamic

To configure the CorsPreflight plugin you should create a middleware in your dynamic configuration as explained here.

File
http:
  middlewares:
    corspreflight-middleware:
      plugin:
        corspreflight:
          errorCode: 200

  routers:
    my-router:
      rule: Host(`localhost`)
      middlewares:
        - corspreflight-middleware
      service: my-service

  services:
    my-service:
      loadBalancer:
        servers:
          - url: 'http://127.0.0.1'
[http.middlewares]
  [http.middlewares.corspreflight-middleware.plugin.corspreflight]
    errorCode = 200

[http.routers]
  [http.routers.my-router]
    rule = "Host(`localhost`)"
    middlewares = ["corspreflight-middleware"]
    service = "my-service"

[http.services]
  [http.services.my-service]
    [http.services.my-service.loadBalancer]
      [[http.services.my-service.loadBalancer.servers]]
        url = "http://127.0.0.1"
Kubernetes
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: corspreflight-middleware
spec:
  plugin:
    corspreflight:
      errorCode: 200

---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: whoami
spec:
  entryPoints:
    - web
  routes:
    - kind: Rule
      match: Host(`whoami.localhost`)
      middlewares:
        - name: corspreflight-middleware
      services:
        - kind: Service
          name: whoami-svc
          port: 80
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: corspreflight-middleware
spec:
  plugin:
    corspreflight:
      errorCode: 200

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: myingress
  annotations:
    traefik.ingress.kubernetes.io/router.middlewares: default-corspreflight-middleware@kubernetescrd

spec:
  rules:
    - host: whoami.localhost
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name:  whoami
                port:
                  number: 80
Docker
version: '3.7'

services:
  whoami:
    image: traefik/whoami:v1.7.1
    labels:
      traefik.enable: 'true'

      traefik.http.routers.app.rule: Host(`whoami.localhost`)
      traefik.http.routers.app.entrypoints: websecure
      traefik.http.routers.app.middlewares: corspreflight-middleware
      
      traefik.http.middlewares.corspreflight-middleware.plugin.corspreflight.errorcode: 200

Developed & Maintained by

Mehdi Youb

License

License

FAQs

Package last updated on 29 Feb 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc