Hi Patrik, thanks for making a guide for implement AMP, that really helps me to make my sitehave amp pages
Implementing AMP-method adds BOM-signature in responses
Im following this guide to implement AMP-pages to my project. https://laravelarticle.com/laravel-amp-optimization
After putting and running protected function mapAmpRoutes() in my routeServiceProvider.php I get a leading BOM-signature (atleast I think it is) in the beginning of all responses from the server.
See this pic from chrome dev tools (red dot before ) https://ibb.co/D9Jz94Y
If I run this in terminal: curl https://mysite.se | less
I get this response always on first line: <U+FEFF><U+FEFF>
If I remove the mapAmpRoutes() the leading BOM disappears. So this method is causing the problem
protected function mapAmpRoutes()
{
Route::prefix('amp')
->middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
I am running laravel 7.2. This leading BOM causes AMP-validation to fail so I think I must pass this. Anyone know whats causing this and how to solve it?
I found a solution for this and thought I should share it if someone else encounters the same problem. Here is the solution:
Save your routes file (web.php) in UTF-8 without BOM. I have in some way managed to change VS Code default setting to save it as UTF-8 with BOM. Problem gone!
Please or to participate in this conversation.