When I deployed to Netlify, it didn’t work, and redicted to 404 page.
I couldn’t see the non-production logs, so I don’t know what happened with Netlify.
Yes, it is. Currently, it is working on another branch, which has yet to be merged to the main, so production doesn’t deploy it.
You can see this code here:
Isn’t that only supposed to work when usig Vite locally? Your comment says server is the vite dev server instance. If you want to use Astro middleware, you should be using it as such: Middleware | Docs.
You cannot run a Node.js server on Netlify. I’m not sure what you’re trying to do at this point, but this doesn’t seem to be the case of Astro not working on Netlify. If you use Astro’s features, they should work.
I also used local development server(netlify dev), and it worked well.
there is a log for this:
❯ netlify dev
◈ Netlify Dev ◈
◈ Injecting environment variable values for all scopes
◈ Ignored general context env var: LANG (defined in process)
◈ Ignored site settings env var: REDIS_URL (defined in .env file)
◈ Injected .env file env var: REDIS_URL
◈ Ignored site settings env var: SQUIDEX_APP_NAME (defined in .env file)
◈ Injected .env file env var: SQUIDEX_APP_NAME
◈ Ignored site settings env var: SQUIDEX_CLIENT_ID (defined in .env file)
◈ Injected .env file env var: SQUIDEX_CLIENT_ID
◈ Ignored site settings env var: SQUIDEX_CLIENT_SECRET (defined in .env file)
◈ Injected .env file env var: SQUIDEX_CLIENT_SECRET
◈ Injected site settings env var: SQUIDEX_ENVIRONMENT
◈ Ignored site settings env var: SQUIDEX_URL (defined in .env file)
◈ Injected .env file env var: SQUIDEX_URL
◈ Ignored site settings env var: WEBHOOK_SECRET (defined in .env file)
◈ Injected .env file env var: WEBHOOK_SECRET
? Multiple possible dev commands found Astro-pnpm run dev
Update your netlify.toml to avoid this selection prompt next time:
[build]
command = “pnpm run build”
publish = “dist”
[dev]
command = “pnpm run dev”
◈ Setting up local development server
Cleaned up .netlify/functions-internal.
◈ Starting Netlify Dev with Astro
example@0.1.2 dev /Users/sgalcheung/Documents/200 - 工作(Work)/220 - 技能(Skill)/221 - CS|计算机科学(Computer Science)/221.2 - 编程语言和编译器(Programming language and compiler)/WebFramework/Astro/starlight-squidex/example
astro dev
14:16:59 [types] Generated 2ms
14:16:59 [vite] Re-optimizing dependencies because lockfile has changed
Waiting for framework port 4321. This can be configured using the ‘targetPort’ property in the netlify.toml
┌─────────────────────────────────────────────────┐
│ │
│ ◈ Server now ready on http://localhost:8888 │
│ │
└─────────────────────────────────────────────────┘
14:17:01 [content] Syncing content
The collection “docs” does not exist or is empty. Ensure a collection directory with this name exists.
14:17:05 [200] / 230ms
My previous statement still stands. You cannot run a Node.js server on Netlify. Could you implement the functionality you require within Astro’s feature set?
First, it is an Astro feature, you can see about it in docs here:
If you ask to implement it, we should make an issue to Astro.
Second, it works well on netlify dev (local development server) but does not work in Netlify’s deploy environment, so why is this situation? Can you confirm this?
A function for integrations to trigger an update to the content layer during astro dev . This can be used, for example, to register a webhook endpoint during dev, or to open a socket to a CMS to listen for changes.
during astro dev being the key word. You’re not running astro dev on Netlify.
@hrishikesh is correct. refreshContent is for astro dev only. It does not work in production. As it says it in the comment in the linked code: this is the Vite dev server.
No, this is the design. It’s not supported in Astro 5 either. We may support live content updates in production one day, but the API would be different.