Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

route context not generating as expected #335

Open
tacman opened this issue Jan 26, 2024 · 5 comments
Open

route context not generating as expected #335

tacman opened this issue Jan 26, 2024 · 5 comments
Labels

Comments

@tacman
Copy link
Contributor

tacman commented Jan 26, 2024

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 tacman added the bug label Jan 26, 2024
@tacman
Copy link
Contributor Author

tacman commented Jan 26, 2024

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
Copy link
Contributor Author

tacman commented Jan 26, 2024

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

@yann-eugone
Copy link
Member

yann-eugone commented Feb 5, 2024

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
Copy link
Member

The MR about the doc was merged, hope this helps

@tacman
Copy link
Contributor Author

tacman commented Feb 5, 2024

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

git clone [email protected]: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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants