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

Astro Image component does not work on Netlify using SSR #4794

Closed
1 task
lgastler opened this issue Sep 18, 2022 · 5 comments · Fixed by #4820
Closed
1 task

Astro Image component does not work on Netlify using SSR #4794

lgastler opened this issue Sep 18, 2022 · 5 comments · Fixed by #4820
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@lgastler
Copy link

What version of astro are you using?

1.2.6

Are you using an SSR adapter? If so, which one?

Netlify

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

The image component does not render images correctly in Production on Netlify using the @astrojs/netlify adapter. Everything works fine in dev mode but once deployed to Netlify the image endpoint fails to generate and return images, instead it throws the following error:

The image "URL" cannot be displayed because it contains errors.

A deployed site using the minimal Reproducible Example can be found here:
https://astro-image-ssr-reproduction.netlify.app/

Link to Minimal Reproducible Example

https://github.com/lgastler/astro-image-ssr-reproduction

Participation

  • I am willing to submit a pull request for this issue.
@matthewp matthewp added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Sep 19, 2022
@matthewp matthewp self-assigned this Sep 19, 2022
@nicatspark
Copy link

This seems to not work again, opening a new issue.

@ezriharmusial
Copy link

Having the Same issues also. Works in development, not in production.

@gregorysirtoli
Copy link

Same issue here, work in dev. not in prod.

@jacob-leger
Copy link

jacob-leger commented Sep 22, 2023

⚠️ EDIT ✏️: I found a solution

It doesn't work for me either! I created an Astro 3 app, excited for the new features, but it doesn't even work on Netlify, the best serverless provider!

And yes, I am using the Netlify adapter. Here is a bit of my config:

export default defineConfig({
	site: // ...
	integrations: [
		mdx(),
		sitemap(),
		prefetch({
			intentSelector: '[data-prefetch]',
			throttle: 10,
		}),
		tailwind(),
		react(),
	],
        output: 'hybrid', // JUST ADD THIS AND IT ALL WORKS! YAY!
	adapter: netlify(),
});

All you have to do is change output: 'server' or output: 'static' to output: 'hybrid'

Btw, I tried output: 'server', but that made my entire site break, not just the images.

I would be willing to help, but I am not very good at Astro.

@Albertyhu
Copy link

Hey @Leiloukou,

I tried your solution. However, my webpages show up blank now.

Here is what my astro.config.mjs file look like

import { defineConfig } from "astro/config";
import tailwind from "@astrojs/tailwind";
import react from "@astrojs/react";
import mdx from "@astrojs/mdx";

import netlify from "@astrojs/netlify";

// https://astro.build/config
export default defineConfig({
  integrations: [tailwind(), react(), mdx()],
  output: "hybrid",
  adapter: netlify(),
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants