Skip to content

Commit

Permalink
Fix CORS issue
Browse files Browse the repository at this point in the history
  • Loading branch information
matchilling committed Jun 19, 2024
1 parent 3627abb commit 918d327
Show file tree
Hide file tree
Showing 8 changed files with 74 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
16 changes: 16 additions & 0 deletions chucknorris-web/src/main/java/io/chucknorris/api/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@ComponentScan(basePackages = {"io.chucknorris"})
@EnableJpaAuditing
@SpringBootApplication
public class Application {

public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry
.addMapping("/**")
.allowCredentials(true)
.allowedHeaders("*")
.allowedMethods("*")
.allowedOrigins("*");
}
};
}

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
Expand Down

This file was deleted.

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 918d327

Please sign in to comment.