Skip to content

admin_pages_dev: Modified Laravel Configurations#182

Merged
Riyad-Murad merged 1 commit intomainfrom
admin_pages_dev
May 21, 2025
Merged

admin_pages_dev: Modified Laravel Configurations#182
Riyad-Murad merged 1 commit intomainfrom
admin_pages_dev

Conversation

@Riyad-Murad
Copy link
Owner

@Riyad-Murad Riyad-Murad commented May 21, 2025

Summary by Sourcery

Configure Laravel application to support CORS and ensure CI workflows populate the APP_URL environment variable

Enhancements:

  • Add CORS configuration file to define API and Sanctum cross-origin settings

CI:

  • Inject APP_URL into .env.example in production and staging GitHub Actions workflows

@sourcery-ai
Copy link

sourcery-ai bot commented May 21, 2025

Reviewer's Guide

This PR enhances deployment workflows by injecting the application URL into the generated .env.example files for both staging and production, and sets up a dedicated CORS configuration in Laravel to allow requests from specified origins.

Sequence Diagram: Updated .env.example Generation in CI/CD

sequenceDiagram
    title "Updated .env.example Generation in CI/CD"
    participant Job as "CI/CD Job"
    participant Script as "Shell Script in Job"
    participant EnvExample as ".env.example"
    participant Secrets as "GitHub Secrets"

    Job->>Script: Execute .env.example generation
    Script->>Secrets: Access LARAVEL_APP_KEY
    Script->>EnvExample: Write APP_KEY (using '>')
    Script->>Secrets: Access EC2_HOST_STAGING
    Script->>EnvExample: Write APP_URL (using '>')
    Script->>Secrets: Access DB credentials etc.
    Script->>EnvExample: Append DB_CONNECTION (using '>>')
    Script->>EnvExample: Append other DB settings (using '>>')
Loading

File-Level Changes

Change Details Files
Add APP_URL environment variable to deployment workflows
  • Insert echo command for APP_URL in production deploy
  • Insert echo command for APP_URL in staging deploy
.github/workflows/stacksDockerDeployProduction.yaml
.github/workflows/stacksDockerDeployStaging.yaml
Introduce CORS configuration for Laravel
  • Create config/cors.php with defined paths, allowed methods
  • Specify allowed origins, headers, and enable credentials support
amp-laravel/config/cors.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Riyad-Murad Riyad-Murad merged commit 13bcec0 into main May 21, 2025
1 check passed
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Riyad-Murad - I've reviewed your changes - here's some feedback:

  • In the GitHub workflows you’re using > for the APP_URL line, which overwrites the file; switch to >> so it appends instead of clobbering previous env entries.
  • Hardcoding http:// and port :8000 in APP_URL may break onboarding in other environments—consider exposing the full URL as a secret or workflow input instead of embedding it.
  • For config/cors.php, pulling allowed origins from an environment variable or a shared config would make it easier to add or remove domains without editing code.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


'allowed_methods' => ['*'],

'allowed_origins' => [
Copy link

Choose a reason for hiding this comment

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

suggestion: Hardcoded CORS origins missing production URL

Use environment variables or allowed_origins_patterns for allowed origins and include your production front-end domain so CORS works in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant