Skip to content

Commit

Permalink
apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Brophy <matt@brophy.org>
  • Loading branch information
mrm007 and brophdawg11 committed Jan 13, 2024
1 parent 24b3c4e commit e998cd0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 7 additions & 4 deletions packages/remix-dev/config/defaults/entry.server.spa.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AppLoadContext, EntryContext } from "@remix-run/node";
import type { EntryContext } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import * as React from "react";
import { renderToString } from "react-dom/server";
Expand All @@ -9,9 +9,12 @@ export default function handleRequest(
responseHeaders: Headers,
remixContext: EntryContext
) {
let html =
"<!DOCTYPE html>\n" +
renderToString(<RemixServer context={remixContext} url={request.url} />);
let html = renderToString(
<RemixServer context={remixContext} url={request.url} />
);
if (html.startsWith("<html")) {
html = "<!DOCTYPE html>\n" + html;
}
return new Response(html, {
headers: { "Content-Type": "text/html" },
status: responseStatusCode,
Expand Down
9 changes: 6 additions & 3 deletions templates/spa/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ export default function handleRequest(
responseHeaders: Headers,
remixContext: EntryContext
) {
const html =
"<!DOCTYPE html>\n" +
renderToString(<RemixServer context={remixContext} url={request.url} />);
let html = renderToString(
<RemixServer context={remixContext} url={request.url} />
);
if (html.startsWith("<html")) {
html = "<!DOCTYPE html>\n" + html;
}
return new Response(html, {
headers: { "Content-Type": "text/html" },
status: responseStatusCode,
Expand Down

0 comments on commit e998cd0

Please sign in to comment.