Skip to content

Commit

Permalink
Fix CORS issue
Browse files Browse the repository at this point in the history
  • Loading branch information
matchilling authored and Matias Schilling committed Jun 19, 2024
1 parent 3627abb commit 4477c2a
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 36 deletions.
2 changes: 2 additions & 0 deletions chucknorris-integration-test/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies {
}
38 changes: 38 additions & 0 deletions chucknorris-integration-test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: '3.8'

services:
database:
image: chucknorrisio/postgres
container_name: chucknorris-database
healthcheck:
interval: 30s
retries: 5
start_period: 80s
test: [ "CMD-SHELL", "pg_isready", "-d", "db_prod" ]
timeout: 60s
ports:
- '5432:5432'

service:
environment:
- APPLICATION_EVENT_SNS_TOPIC_ARN=my-application-event-sns-topic-arn
- AWS_ACCESS_KEY_ID=my-aws-access-key-id
- AWS_ACCESS_KEY_SECRET=my-aws-access-key-secret
- AWS_REGION=my-aws-region
- DAILYCHUCK_BUCKET_NAME=my-dailychuck-bucket-name
- DAILYCHUCK_KEY_NAME=my-dailychuck-key-name
- DATABASE_URL=postgres://postgres:postgres@database:5432/chuck
- MAILCHIMP_API_KEY=my-mailchimp-api-key
- MAILCHIMP_DAILYCHUCK_LIST_ID=my-mailchimp-dailychuck-list-id
- SLACK_CONTENT_WHITELISTED_CATEGORIES=career,dev,fashion,food,money,movie,travel
- SLACK_OAUTH_ACCESS_TOKEN=xxxx-xxxxxxxxxxx-xxxxxxxxxxx-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- SLACK_OAUTH_CLIENT_ID=xxxxxxxxxxx.xxxxxxxxxxxx
- SLACK_OAUTH_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- SLACK_OAUTH_REDIRECT_URI=https://api.chucknorris.io/connect/slack
image: chucknorris/chucknorris-web
container_name: chucknorris-web
depends_on:
database:
condition: service_healthy
ports:
- '8080:8080'
16 changes: 16 additions & 0 deletions chucknorris-integration-test/script/run-integration-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

readonly SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
readonly MODULE_DIR=$(cd "${SCRIPT_DIR}/.." && pwd)
readonly PROJECT_DIR=$(cd "${SCRIPT_DIR}/../.." && pwd)

./gradlew --build-file "$PROJECT_DIR/build.gradle" clean dockerTagCurrent

# docker-compose --file "$MODULE_DIR/docker-compose.yml" up \
# --exit-code-from "integration-test" \
# --quiet-pull \
# --remove-orphans

docker-compose --file "$MODULE_DIR/docker-compose.yml" up \
--quiet-pull \
--remove-orphans

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.chucknorris.api.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig {

@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry
.addMapping("/**")
.allowedHeaders("*")
.allowedMethods("*")
.allowedOrigins("*")
.exposedHeaders("Access-Control-Allow-Origin Access-Control-Allow-Credentials");
}
};
}
}
8 changes: 0 additions & 8 deletions docker-compose.yml

This file was deleted.

1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.logging.level=quiet
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

rootProject.name = 'chucknorris'

include("chucknorris-integration-test")
include("chucknorris-web")

0 comments on commit 4477c2a

Please sign in to comment.