Challenge - 5 Problems
Astro Node.js Adapter Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediateHow does the Node.js adapter handle server startup in Astro?
In an Astro project using the Node.js adapter for self-hosting, what happens when you run the server with the adapter?
Attempts:
2 left
💡 Hint
Think about how Node.js servers usually handle requests.
✗ Incorrect
The Node.js adapter for Astro creates a server (often using Express or similar) that listens on a port and serves the Astro pages dynamically. This allows self-hosting with full server capabilities.
📝 Syntax
intermediateCorrect import statement for Node.js adapter in Astro config
Which import statement correctly imports the Node.js adapter in an Astro configuration file?
Attempts:
2 left
💡 Hint
Check the official package name and import style for Astro adapters.
✗ Incorrect
The official Node.js adapter for Astro is imported as node from @astrojs/node using ES module syntax.
🔧 Debug
advancedWhy does the Node.js adapter server crash on startup?
Given this Astro config snippet using the Node.js adapter, the server crashes on startup with an error about missing 'port'. What is the likely cause?
export default {
adapter: node(),
server: {
host: '0.0.0.0'
}
}Attempts:
2 left
💡 Hint
Servers need a port number to listen on.
✗ Incorrect
The Node.js adapter requires a port number to bind the server. Omitting the port causes the server to fail starting.
❓ state_output
advancedWhat is the output when running Astro with Node.js adapter and environment variable PORT=8080?
If you run an Astro project with the Node.js adapter and set the environment variable
PORT=8080, which port will the server listen on by default?Attempts:
2 left
💡 Hint
Environment variables often override default settings.
✗ Incorrect
The Node.js adapter respects the PORT environment variable and listens on that port if set.
🧠 Conceptual
expertWhy choose the Node.js adapter for self-hosting Astro over static export?
Which reason best explains why a developer would choose the Node.js adapter for self-hosting an Astro site instead of using Astro's static site generation?
Attempts:
2 left
💡 Hint
Think about when you need a server to run code on demand.
✗ Incorrect
The Node.js adapter allows running server-side code and dynamic routes, which static export cannot handle.
