# CORS Configuration Protection

## Problem
When running `php artisan vendor:publish --force --all`, the `config/cors.php` file gets overwritten by the default configuration from the `fruitcake/laravel-cors` package.

## Solution
We've implemented a custom artisan command that automatically protects your `cors.php` file during vendor publishing.

## Usage

### Option 1: Use the Safe Publish Command (Recommended)
Instead of running:
```bash
php artisan vendor:publish --force --all
```

Run this command instead:
```bash
php artisan vendor:publish-safe --force --all
```

This command will:
1. Automatically backup your current `cors.php` file
2. Run the vendor:publish command with your specified options
3. Restore your original `cors.php` file
4. Clean up temporary files

### Option 2: Manual Backup and Restore
If you prefer to use the standard vendor:publish command:

```bash
# Step 1: Run vendor:publish as usual
php artisan vendor:publish --force --all

# Step 2: Restore your cors.php configuration
php artisan config:restore-cors
```

## Files Created

1. **app/Console/Commands/SafeVendorPublish.php**
   - Custom command that wraps vendor:publish with automatic cors.php protection

2. **app/Console/Commands/RestoreCorsConfig.php**
   - Command to manually restore cors.php from backup

3. **app/Providers/PreventCorsPublishServiceProvider.php**
   - Service provider that attempts to prevent cors.php from being published (alternative approach)

4. **config/cors.php.backup**
   - Backup of your current cors.php configuration

## Recommendation

**Always use `php artisan vendor:publish-safe --force --all` in production** to ensure your custom CORS configuration is never accidentally overwritten.

## Alternative: Exclude Specific Tags

If you want to publish everything except CORS config, you can also use:
```bash
# Publish specific tags only
php artisan vendor:publish --tag=public --force
php artisan vendor:publish --tag=views --force
# etc...
```

To see all available tags:
```bash
php artisan vendor:publish --help
```
