I am trying to generate a sitemap for my website but I can't, my website is using laravel octane. The urls that the spatie/laravel-sitemap package generates are like these:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>http://127.0.0.1:8000/</loc>
<lastmod>2022-08-27T00:17:40+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>http://127.0.0.1:8000/my-url</loc>
<lastmod>2022-08-27T00:17:40+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
It is no setting the proper url domain: http://myweb.com/my-url it is generating this http://127.0.0.1:8000/my-url . I am using nginx as reverse proxy and the requests are redirected to octane, as the laravel docs says : https://laravel.com/docs/9.x/octane#serving-your-application-via-https
Also the sitemap is being generated using a command:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\URL;
use Spatie\Sitemap\SitemapGenerator;
class GenerateSitemap extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sitemap:generate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate the sitemap';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
//SitemapGenerator::create(config('app.url'))
SitemapGenerator::create('https://myweb.com')
->writeToFile(public_path('sitemap.xml'));
}
}
and that command is called in the scheduler:
$schedule->command('sitemap:generate')->daily();
What can I do? thanks