Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cors settings #103

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add cors settings #103

wants to merge 3 commits into from

Conversation

Mtze
Copy link
Member

@Mtze Mtze commented Sep 30, 2024

No description provided.

@Mtze Mtze self-assigned this Sep 30, 2024
allowed-origins: {{ artemis_CORS_allowed_origins }}
{% if artemis_cors is defined and artemis_cors is not none %}
artemis_cors:
{% for key, value in cors.items() %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should be artemis_cors instead of cors

Suggested change
{% for key, value in cors.items() %}
{% for key, value in artemis_cors.items() %}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also why do you iterate through the dict and then convert each entry to yaml instead of just converting the entire dict directly to yaml?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another question: I see the point of not hard coding the keys and having the option of the dynamic configuration, but in the artemis.env.j2 file the keys are hard coded.

Therefore, I would prefer an homogeneous approach and that the keys are hard coded here as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I reiterated over that because I need a similar approach for something else (Theia configuration). Thus, I came up with a potential approach for a dynamic configuration in the environment file.

Comment on lines +254 to +262
# artemis_cors:
# allowed_methods: "*"
# allowed_headers: "*"
# exposed_headers: "Authorization,Link,X-Total-Count,Set-Cookie"
# allow_credentials: true
# max_age: 1800
# allowed_origins:
# - "vscode-file://vscode-app"
# - "vscode-webview://*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it makes sense to have this as a default if theia is defined?

allowed-origins: {{ artemis_CORS_allowed_origins }}
{% if artemis_cors is defined and artemis_cors is not none %}
artemis_cors:
{% for key, value in cors.items() %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another question: I see the point of not hard coding the keys and having the option of the dynamic configuration, but in the artemis.env.j2 file the keys are hard coded.

Therefore, I would prefer an homogeneous approach and that the keys are hard coded here as well.

@bensofficial bensofficial added enhancement New feature or request role.artemis labels Oct 1, 2024
Comment on lines +238 to +243
JHIPSTER_CORS_ALLOWEDMETHODS='{{ artemis_cors.allowed_methods | join(',') }}'
JHIPSTER_CORS_ALLOWEDHEADERS='{{ artemis_cors.allowed_headers | join(',') }}'
JHIPSTER_CORS_EXPOSEDHEADERS='{{ artemis_cors.exposed_headers }}'
JHIPSTER_CORS_ALLOWCREDENTIALS='{{ artemis_cors.allow_credentials }}'
JHIPSTER_CORS_MAXAGE='{{ artemis_cors.max_age }}'
JHIPSTER_CORS_ALLOWEDORIGINS='{{ artemis_cors.allowed_origins | join(',') }}'
Copy link
Member

@bensofficial bensofficial Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
JHIPSTER_CORS_ALLOWEDMETHODS='{{ artemis_cors.allowed_methods | join(',') }}'
JHIPSTER_CORS_ALLOWEDHEADERS='{{ artemis_cors.allowed_headers | join(',') }}'
JHIPSTER_CORS_EXPOSEDHEADERS='{{ artemis_cors.exposed_headers }}'
JHIPSTER_CORS_ALLOWCREDENTIALS='{{ artemis_cors.allow_credentials }}'
JHIPSTER_CORS_MAXAGE='{{ artemis_cors.max_age }}'
JHIPSTER_CORS_ALLOWEDORIGINS='{{ artemis_cors.allowed_origins | join(',') }}'
{% for key, value in artemis_cors.items() %}
JHIPSTER_CORS_{{ key | upper | regex_replace ("[^A-Z0-9]","") }}='{{ value | join(',') }}'
{% endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request role.artemis
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants