Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ijo42/corsmiddleware
https://github.com/ijo42/corsmiddleware
traefik-plugin
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ijo42/corsmiddleware
- Owner: ijo42
- License: apache-2.0
- Created: 2024-08-14T08:38:13.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-08-15T19:50:59.000Z (3 months ago)
- Last Synced: 2024-08-16T07:29:50.080Z (3 months ago)
- Topics: traefik-plugin
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Patch for https://github.com/SergioFloresG/corsmiddleware/pull/2
[![Main](https://github.com/SergioFloresG/corsmiddleware/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/SergioFloresG/traefik-cors-middleware/actions/workflows/main.yml)
[![Matrix](https://github.com/SergioFloresG/corsmiddleware/actions/workflows/go-cross.yml/badge.svg?branch=master)](https://github.com/SergioFloresG/traefik-cors-middleware/actions/workflows/go-cross.yml)The existing plugins can be browsed into the [Plugin Catalog](https://plugins.traefik.io).
## Usage
Use this middleware to add CORS support to the necessary endpoints, indicating their domain, allowed methods and more.
### Configuration
Requirements: Traefik >= v2.5.5
| Option | Description | Header |
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| `allowCredentials` | This indicates whether or not the actual request can be made using credentials.
_(default: `false`)_ | [Access Control Allow Credentials](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials) |
| `allowOrigins` | Indicates the group of sources that have access to the requesting resource.
_(default: `*`)_ | [Access Control Allow Origin](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin) |
| `allowMethods` | Specifies one or more methods allowed when accessing a resource in response.
_(default: `OPTIONS`, `GET`, `POST`, `PUT`, `DELETE`)_ | [Access Control Allow Methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods) |
| `allowHeaders` | Indicate which HTTP headers can be used during the actual request. the indicated headers are an addition to [default ones](#allow_headers_defaults) | [Access Control Allow Headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers) |
| `exposeHeaders` | Indicate which response headers should be made available to scripts running in the browser, in response to a cross-origin request. | [Access Control Expose Headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers) |
| `maxAge`: | Indicates how long the results of a preflight request can be cached
_(default: `86400`)_ | [Access Control Max Age](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age) |
**Default Allow Headers**: Content-Type, Content-Length, Accept-Encoding, Authorization, Accept, Origin, Referer,
Cache-Control#### Traefik
```yaml
# Static configurationexperimental:
plugins:
example:
moduleName: github.com/SergioFloresG/corsmiddleware
version: v0.1.0
```Here is an example of a file provider dynamic configuration (given here in YAML), where the interesting part is
the `http.middlewares` section:```yaml
# Dynamic configurationhttp:
routers:
my-router:
rule: host(`demo.localhost`)
service: service-foo
entryPoints:
- web
middlewares:
- my-cors-middlewareservices:
service-foo:
loadBalancer:
servers:
- url: http://127.0.0.1:5000middlewares:
my-cors-middleware:
plugin:
corsmiddleware:
allowOrigins: ["https://example.com"]
```