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

Unable to generate RSS feed with directory format consistently across DEV and PROD environments #11447

Open
1 task
eikowagenknecht opened this issue Jul 10, 2024 · 3 comments
Assignees
Labels
- P2: has workaround Bug, but has workaround (priority) pkg: rss Related to the `@astrojs/rss` package (scope) requires refactor Bug, may take longer as fixing either requires refactors, breaking changes, or considering tradeoffs

Comments

@eikowagenknecht
Copy link

Astro Info

Astro                    v4.11.5
Node                     v20.11.1
System                   Windows (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind
                         @astrojs/react
                         @astrojs/sitemap
                         @astrojs/mdx

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

For my site, I use the "directory" format: https://example.com/page/

I would like to have my RSS feed like this as well: https://example.com/feed/

But I can't find any combination of the generating endpoint file name, trailingSlash and build.format to achieve this.

File /pages/feed.js, trailingSlash: always, build.format: directory:
-> DEV: /feed has a 404, /feed/ works. PROD: Generates /feed file, /feed/ has a 404

File /pages/feed/index.js, trailingSlash: always, build.format: directory:
-> Same behaviour as /pages/feed.js

If it's not possible to put an RSS feed as a directory, I would be kind of content with just using /rss.xml, but that has it's own problem: It is not reachable on the DEV server any more.

File /pages/rss.xml.js, trailingSlash: always, build.format: directory:
-> DEV: /rss.xml has a 404, /rss.xml/ works. PROD: Generates /rss.xml file, /rss.xml/ has a 404

What's the expected result?

There should be a combination of trailingShash and build.format that behaves consistently for DEV and PROD for endpoint routes.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-6vyntu

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jul 10, 2024
@ematipico
Copy link
Member

Have you tried the build format preserve? https://docs.astro.build/en/reference/configuration-reference/#buildformat

I think that's what you're looking for...

@ematipico ematipico added the needs response Issue needs response from OP label Jul 19, 2024
@eikowagenknecht
Copy link
Author

eikowagenknecht commented Jul 22, 2024

I've tried that one as well, the result is still the same for the feed:

File pages/feed.js, trailingSlash: always, build.format: preserve:

  • DEV
    • /feed: 404 error
    • /feed/: Shows the RSS
  • PROD
    • /feed: Shows the RSS
    • /feed/: 404 error

Also, all other links show in file style (e.g. https://example.com/blog instead of https://example.com/blog/) now, which is not what I want.

It seems like for endpoint rules (xyz.js files), no matter what is set as build.format, the output is always xyz.

feed.js > feed
feed.xml.js > feed.xml
feed/index.js > feed
feed.xml/index.js > feed.xml
feed.xml/index.html.js > feed.xml.html

All output is always in the root, no directory is created.

@Princesseuh Princesseuh added needs triage Issue needs to be triaged and removed needs triage Issue needs to be triaged needs response Issue needs response from OP labels Jul 30, 2024
@Princesseuh Princesseuh added pkg: rss Related to the `@astrojs/rss` package (scope) - P3: minor bug An edge case that only affects very specific usage (priority) and removed needs triage Issue needs to be triaged labels Aug 8, 2024
@ematipico ematipico self-assigned this Aug 15, 2024
@ematipico
Copy link
Member

Ok, I know what's the issue, and it's not the first one.

The issue is that we impose trailingSlash on endpoints too. It's not the first issue that was filed, however we can't change the behaviour lightly.

We plan to change this behaviour in Astro 5.0, by not applying trailingSlash to endpoints. This will be a breaking change.

The only workaround that I can suggest is to change is to use trailingSlash: ignore, however I know that probably won't solve your issue.

@ematipico ematipico added - P2: has workaround Bug, but has workaround (priority) requires refactor Bug, may take longer as fixing either requires refactors, breaking changes, or considering tradeoffs and removed - P3: minor bug An edge case that only affects very specific usage (priority) labels Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) pkg: rss Related to the `@astrojs/rss` package (scope) requires refactor Bug, may take longer as fixing either requires refactors, breaking changes, or considering tradeoffs
Projects
None yet
Development

No branches or pull requests

3 participants