hashicorp / hashicorp/nomad

Unable to perform any non-GET request due to CORS

Open
#4,601 3 comments 1 reaction 0 assignees View on GitHub
stage/needs-verification theme/api type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

If you have a question, prepend your issue with `[question]` or preferably use the [nomad mailing list](https://www.nomadproject.io/community.html).

If filing a bug please include the following:

### Nomad version
Nomad v0.8.4 (dbee1d7d051619e90a809c23cf7e55750900742a)

### Operating system and Environment details
Ubuntu 16.04

### Issue
When attempting to perform a non-GET request to the http api from a browser, I recieve the following error:
```
OPTIONS http://localhost:9878/v1/job/gc

Fetch API cannot load http://localhost:9878/v1/job/gc. Response to preflight request doesn't pass access
control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin
'http://localhost:1234' is therefore not allowed access. The response had HTTP status code 404. If an
opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS
disabled.
```

I have the following in my config file:
```
http_api_response_headers {
"Access-Control-Allow-Origin" = "*"
"Access-Control-Allow-Methods" = "POST, GET, OPTIONS, PUT, DELETE"
"Access-Control-Allow-Headers" = "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization"
}
```

### Reproduction steps
Try and perform an non-GET http request from the browser.

### Nomad Server logs (if appropriate)

### Nomad Client logs (if appropriate)

### Job file (if appropriate)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.