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 set SEO site url to cloudflare deployment-url #469

Open
lorenzofiamingo opened this issue Feb 13, 2025 · 3 comments
Open

Unable to set SEO site url to cloudflare deployment-url #469

lorenzofiamingo opened this issue Feb 13, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@lorenzofiamingo
Copy link

I use the following workflow to deploy my website:

name: Deploy to NuxtHub
on: push

jobs:
  deploy:
    name: "Deploy to NuxtHub"
    runs-on: ubuntu-latest
    environment:
      name: ${{ github.ref_name == 'main' && 'production' || 'preview' }}
      url: ${{ steps.deploy.outputs.deployment-url }}
    permissions:
      contents: read
      id-token: write

    steps:
      - uses: actions/checkout@v4

      - name: Install bun
        uses: oven-sh/setup-bun@v1

      - name: Install dependencies
        run: bun install

      - name: Build application
        run: bun run build
        env:
          NUXT_UI_PRO_LICENSE: ${{ secrets.NUXT_UI_PRO_LICENSE }}
          NUXT_SITE_URL: ${{ steps.deploy.outputs.deployment-url }}  # not working: deploy is not started yet

      - name: Deploy to NuxtHub
        uses: nuxt-hub/action@v1
        id: deploy
        with:
          project-key: eutimo-1zgd

Is there a way to retrieve the deployment-url earlier, or to set it after the build phase? I cannot retrieve the commit hash, as it is generated by Cloudflare. Therefore, using the first part of github.sha is not an option. It's actually feasible what I'm attempting to do?

@lorenzofiamingo lorenzofiamingo added the enhancement New feature or request label Feb 13, 2025
@lorenzofiamingo lorenzofiamingo changed the title Unable to set SEO site url to deployment url Unable to set SEO site url to cloudflare deployment-url Feb 13, 2025
@lorenzofiamingo
Copy link
Author

For now I'm using this, but is not working well for older commits deployment in preview branches:

NUXT_SITE_URL: ${{ github.ref_name == 'main' && 'https://example.pages.dev' || format('https://{0}.example.pages.dev', github.ref_name) }} 

Copy link
Contributor

atinux commented Feb 14, 2025

How do you use the site url in your code? if there is no pre-rendering, you can get the url using useRequestUrl()

<script setup>
const url = useRequestURL()
</script>

@lorenzofiamingo
Copy link
Author

Thank you for the reply, @atinux. I use the site URL for the Nuxt SEO module, primarily for OG images that are pre-rendered by the module, so I can’t use useRequestURL. To be honest, my situation is not a big problem, but it would be nice to have the ability to inject some NuxtHub variables in the app, like the generated deployment ID, into the environment.

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

No branches or pull requests

2 participants