Skip to content

Conversation

@memotux
Copy link
Contributor

@memotux memotux commented May 8, 2025

πŸ”— Linked issue

resolves #3337

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Add sql_dump routes url file extension .txt (including tests). In version 3.5.0 was explicitly set dump's content type to text/plain (#3302). It will be good practice to set the dump file extension to .txt.

It is known that files without extension in AWS Amplify does not work: aws-amplify/amplify-hosting#225

When you manual deploy a Nuxt project to AWS Amplify, in local environment build the project with nuxt generate. The sql_dump file is pre-rendered without a file extension.

If sql_dump file is uploaded without extension to AWS Amplify, the environment will delete it, causing a 404 error, when sql_dump file is fetched.

Resolves #3337

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 8, 2025

npm i https://pkg.pr.new/@nuxt/content@3339

commit: 2f3afd2

@farnabaz
Copy link
Member

Thanks you for the PR @memotux,
Due to 404 issue, the dump pretender is disabled in AWS Amplify preset.

I have a favor to ask: Since you already checked this code in AWS Amplify, could you try to comment on these lines in src/presets/aws_amplify.ts and try to deploy your project?

    // Fetching assets on server side is not working with AWS Amplify
    // Disable prerendering to avoid fetching assets on server side
    Object.keys(nuxt.options.routeRules || {}).forEach((route) => {
      if (route.startsWith('/__nuxt_content/') && route.endsWith('/sql_dump.txt')) {
        nuxt.options.routeRules![route].prerender = false
      }
    })

With your fix, we might not need to disable pre-rendering.

@memotux
Copy link
Contributor Author

memotux commented May 15, 2025

Thanks you for the PR @memotux, Due to 404 issue, the dump pretender is disabled in AWS Amplify preset.

I have a favor to ask: Since you already checked this code in AWS Amplify, could you try to comment on these lines in src/presets/aws_amplify.ts and try to deploy your project?

    // Fetching assets on server side is not working with AWS Amplify
    // Disable prerendering to avoid fetching assets on server side
    Object.keys(nuxt.options.routeRules || {}).forEach((route) => {
      if (route.startsWith('/__nuxt_content/') && route.endsWith('/sql_dump.txt')) {
        nuxt.options.routeRules![route].prerender = false
      }
    })

With your fix, we might not need to disable pre-rendering.

Hi @farnabaz. I have done as asked. Comment out that lines. Run nuxt build (SSR) on AWS Amplify environment. The RESULT: 500 error. If sql_dump is not prerender, works OK. It seems a restriction on Amplify to fetch files on "Static target" (public static files) from "Compute target" (server).

This lines should stay as it is, but only in SSR (nuxt build or !nuxt.options.nitro.static). In SSG (nuxt generate or nuxt.options.nitro.static) the route should prerender. (May be another PR?)

Copy link
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@farnabaz farnabaz merged commit d0ceeb6 into nuxt:main May 21, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dump file is deleted on AWS Amplify static deployment

2 participants