ProjectEvergreen / greenwood

Greenwood is your workbench for the web, embracing web standards from the ground up to empower your stack from front to back.
https://www.greenwoodjs.io
MIT License
96 stars 9 forks source link

SSR pages with `prerender` configuration are not getting served from static HTML #1099

Closed thescientist13 closed 1 year ago

thescientist13 commented 1 year ago

Type of Change

Bug

Summary

After upgrading to v0.28.0, noticed that when introduced API routes into a "static" project, this combination triggers the hybrid server and now the HTML coming back for the home page is showing a bunch of 404s because it is being served from index.js instead of the static index.html output. (which actually revealed another bug).

Screen Shot 2023-04-15 at 2 25 03 PM

<link rel="stylesheet" href="../styles/main.css" data-gwd-opt="inline">

<script type="module" data-gwd-opt="static" src="../components/footer/footer.js"></script>
<script type="module" data-gwd-opt="static" src="../components/header/header.js"></script>
<script type="module" src="../components/nav/nav.js"></script>
<script type="module" src="../components/video-card/video-card.js"></script>

As a note, seems like these shouldn't be returning a 500 though, should be a 404.

Details

However, what is key to note about the difference between this and #1098 is that this project has prerender: true in its greenwood.config.js which means this page should not be serving from index.js. The output index.html is correctly bundled, and that is what should be being served.

In fact, there's no reason for this to even need a bundled index.js in the first place.

% tree public
public
├── 2002200397.827098fd.js.map
├── 404
├── 404.html
├── _index.js
├── _templates
│   └── app.html
├── api
│   ├── assets
│   │   └── video-card-8a4d9eb0.js
│   ├── fragment.js
│   └── greeting.js
├── assets
│   ├── fonts
│   │   └── coop-bl.woff2
│   ├── icons
│   │   ├── facebook.svg
│   │   ├── spotify.svg
│   │   └── youtube.svg
│   ├── images
│   │   ├── avatar-dave.webp
│   │   ├── avatar-erika.webp
│   │   ├── avatar-owen.webp
│   │   └── avatar-tunesy.webp
│   ├── tuesdays-tunes-og.png
│   ├── tuesdays-tunes.webp
│   └── tunesy.webp
├── contact
│   └── index.html
├── favicon.ico
├── footer.5d06a040.js.map
├── graph.json
├── header.ebe96d78.js.map
├── index.html
├── index.js
├── manifest.json
├── nav.97858d20.js
├── nav.97858d20.js.map
├── resources.json
├── styles
├── video-card.1048ec31.js
└── video-card.1048ec31.js.map

10 directories, 31 files