prestaconcept / PrestaSitemapBundle

A symfony bundle that provides tools to build a rich application sitemap. The main goals are : simple, no databases, various namespace (eg. google image), respect constraints etc.
MIT License
357 stars 102 forks source link

route context not generating as expected #335

Open tacman opened 9 months ago

tacman commented 9 months ago

Package version(s) affected: 4.0

Description

When dumping routes, Symfony uses the context. The description in the documentation isn't right, it should be

https://symfony.com/blog/new-in-symfony-5-1-simpler-request-context

But regardless, I'm having trouble getting it to work.

It shouldn't just be the dump command, it should be in the generation as well for dynamic routes.

tacman commented 9 months ago

https://presta.wip/sitemap.xml

I want to define my own route there and when I dump, when I dump I get the IP address and port.

image

framework:
    router:
        default_uri: 'https://example.org/my/path/'
parameters:
    asset.request_context.base_path: my-proxy-domain.wip:9001
    asset.request_context.secure: true
    # config/services.yaml
    router.request_context.scheme: 'https'
tacman commented 9 months ago

I can check in my changes to the demo proxy, using Symfony 7, if that helps.

yann-eugone commented 9 months ago

I've checked this thing on my side, and it seems to work like a charm :

# config/packages/routing.yaml
framework:
    router:
        default_uri: 'https://my-wonderful-host.com/prefixed'
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd"
              xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://my-wonderful-host.com/sitemap.default.xml</loc>
    <lastmod>2024-02-05T09:18:28+01:00</lastmod>
  </sitemap>
</sitemapindex>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://my-wonderful-host.com/prefixed/</loc>
    <lastmod>2024-02-05T09:18:28+01:00</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.5</priority>
  </url>
  <url>
    <loc>https://my-wonderful-host.com/prefixed/about</loc>
    <lastmod>2024-01-23T11:52:33+01:00</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.5</priority>
  </url>
  <url>
    <loc>https://my-wonderful-host.com/prefixed/notre-expertise</loc>
    <lastmod>2024-01-24T11:52:36+01:00</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.5</priority>
  </url>

</urlset>

presta/sitemap-bundle                    4.x-dev 6c5d03d A Symfony bundle that provides tools to build your application sitemap.
symfony/framework-bundle                 v6.3.0          Provides a tight integration between Symfony components and the Symfony full-stack framework
symfony/routing                          v6.3.0          Maps an HTTP request to a set of configuration variables
yann-eugone commented 9 months ago

The MR about the doc was merged, hope this helps

tacman commented 9 months ago

Hmm, not working for me. Can you try with my fork please?

git clone git@github.com:tacman/presta-sitemap-test-project.git presta && cd presta
composer install
bin/console doctrine:database:create
bin/console doctrine:schema:update --force --complete
bin/console doctrine:fixtures:load --no-interaction
symfony server:start -d
symfony open:local --path=sitemap.xml
cat config/packages/routing.yaml 
framework:
    router:
        # Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
        # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
        #default_uri: http://localhost
        default_uri: 'https://my-wonderful-host.com/prefixed'

when@prod:
    framework:
        router:
            strict_requirements: null