diff --git a/.github/actions/deploy/backend/action.yml b/.github/actions/deploy/backend/action.yml index a1c62ba7..f99cab46 100644 --- a/.github/actions/deploy/backend/action.yml +++ b/.github/actions/deploy/backend/action.yml @@ -37,7 +37,15 @@ runs: with: go-version: '1.23' - - name: 'Create env file' + - name: Build the app + shell: bash + working-directory: ./go + run: | + go mod download + GOOS=linux go build -o bin/app cmd/main.go + + - name: Create env file + working-directory: ./go/bin shell: bash run: | touch .env @@ -47,14 +55,7 @@ runs: echo DB_PASSWORD=${{ inputs.db_password }} >> .env echo DB_NAME=${{ inputs.db_name }} >> .env - - name: Build the app - shell: bash - working-directory: ./go - run: | - go mod download - GOOS=linux go build -o bin/app cmd/main.go - - - name: Deploy to my EC2 instance + - name: Deploy to EC2 instance uses: easingthemes/ssh-deploy@v5.1.0 with: REMOTE_HOST: 'ec2-13-41-72-100.eu-west-2.compute.amazonaws.com' diff --git a/go/rpc/module.go b/go/rpc/module.go index 5eea75a7..f0315bff 100644 --- a/go/rpc/module.go +++ b/go/rpc/module.go @@ -3,6 +3,7 @@ package rpc import ( "context" "net/http" + "os" "connectrpc.com/connect" connectcors "connectrpc.com/cors" @@ -104,10 +105,7 @@ func registerHandlers(lc fx.Lifecycle, handlers []Handler, options []connect.Han func withCORS(h http.Handler) http.Handler { middleware := cors.New(cors.Options{ - AllowedOrigins: []string{ - "https://localhost:5173", - "http://vue-js-app.s3-website.eu-west-2.amazonaws.com", - }, + AllowedOrigins: []string{os.Getenv("CORS_ALLOWED_ORIGIN")}, AllowedMethods: []string{ http.MethodGet, http.MethodPost,