To address the issue you're facing with the APP_URL in your Laravel application, you need to ensure that the APP_URL in your .env file is set to the external URL that users will access, which in your case is https://laravel.mysite.co.uk/myappservice.
Here are the steps to resolve the issue:
-
Update the
.envfile: Set theAPP_URLin your.envfile to the external URL that includes the path/myappservice.APP_URL=https://laravel.mysite.co.uk/myappservice -
Update the
config/app.phpfile: Ensure that theurlconfiguration inconfig/app.phpis set to use theAPP_URLfrom the environment file.'url' => env('APP_URL', 'https://laravel.mysite.co.uk/myappservice'), -
Handle URL Generation: Laravel uses the
APP_URLto generate URLs for assets, routes, and other links. By setting theAPP_URLcorrectly, Laravel will generate the correct URLs. -
Clear Configuration Cache: If you have cached your configuration, you need to clear it so that the changes take effect.
php artisan config:cache -
Check Rewrite Rules: Ensure that your Azure Application Gateway rewrite rules are correctly set up to forward requests to your Docker container. The rewrite rules should not alter the path structure that Laravel expects.
-
Asset URLs: If you are using Laravel Mix or any other asset management tool, ensure that the URLs generated for your CSS and JS files are correct. You might need to update the
mixconfiguration if necessary.For example, in
webpack.mix.js:mix.setResourceRoot('/myappservice/');
By following these steps, your Laravel application should generate URLs that include the /myappservice path, ensuring that links and assets are correctly referenced.
If you continue to experience issues, you might want to check the following:
- Ensure that there are no hardcoded URLs in your views or assets that do not include the
/myappservicepath. - Verify that the Azure Application Gateway is correctly forwarding the requests without altering the expected paths.
This should resolve the issue with incorrect URLs being generated in your Laravel application.