How to clear CORS and request Rest API in Redmine official Docker

Asked 2 years ago, Updated 2 years ago, 382 views

Launched the container from the official Redmine image of Docker.
Kick Rest API to Redmine from Vuejs self-made front end.
As a result, the following CORS errors occurred:
I want to solve this problem.
Downloading the plug-in redmine_cors from GitHub and configuring the allowed domain from the web screen did not resolve it.
There are few references and the cause is unknown.

Error Description:

Access to XMLHttpRequest at'http://localhost:3000/projects/sample/issues.json?query_id=8'from origin'http://localhost:8080' has been blocked by CORS policy:Response to prelight request does't-acceptance' Course: All

Header to request to Redmine:

 'Content-Type': 'application/json'
'Access-Control-Allow-Origin': '*'
'X-Redmine-API-Key': 'Access Key'

The following is the Docker Composer YML file.

version: '3.8'
services:
  redmine:
    build:
      context:.
      dockerfile —Dockerfile.dockerfile
    container_name —redmine
    ports:
      - 3000:3000
    environment:
      REDMINE_DB_MYSQL —redmine-db
      REDMINE_DB_PASSWORD:redmine
      command: /bin/bash
    depend_on:
      - redmine-db
    restart —always
    
  redmine-db:
    image —mariadb
    container_name —redmine-db
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD—redmine
      MYSQL_DATABASE:redmine
    command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci
    restart —always

Docker file.
Downloaded the plug-in from GitHub for CORS protection.
Attempted to lower the version from the latest to match the Redmine version of the site referenced in the error when placed in a given directory.
Also, the sed command stated that the match should be changed to get.

 FROM redmine: 3.0.6

# CORS
RUN apt-get update-y
RUN apt-get install git-y
RUN cd/usr/src/redmine/plugins/&git clone https://github.com/mavimo/redmine_cors.git-b v0.0.1
RUN sed-i-e's/match/get/g'/usr/src/redmine/plugins/redmine_cors/config/routes.rb

Docker's official Redmine image

redmine cors

2022-10-25 00:01

1 Answers

I solved myself.
As a result of changing the library I use, it worked.

The library used is rack-cors.
The library I used in the questionnaire was redmine_cors", but I think there was probably no compatible version.The last update date was 7 years ago.

The steps are as follows:


2022-10-25 00:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.