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

Content-Type header is missing in responses of starter project #712

Closed
1 of 2 tasks
alaendle opened this issue Oct 22, 2023 · 2 comments · Fixed by #717
Closed
1 of 2 tasks

Content-Type header is missing in responses of starter project #712

alaendle opened this issue Oct 22, 2023 · 2 comments · Fixed by #717
Assignees
Labels
accepting PRs bug Something isn't working

Comments

@alaendle
Copy link
Contributor

alaendle commented Oct 22, 2023

Please provide the environment you discovered this bug in.

GitHub codespace on https://github.com/alaendle/meta-framework-playground/tree/eb34a638d2fe0430ad9ccb169b89182a65dd1d9c

Which area/package is the issue in?

Don't know / other

Description

Following https://analogjs.org/docs/getting-started#creating-a-new-application and directly starting via npm install && npm run start - curl http://localhost:5173/ -v shows that the response doesn't include a Content-Type header and browsers will display the response as plain text.

Please provide the exception or error you saw

curl http://localhost:5173/ -v
*   Trying 127.0.0.1:5173...
* connect to 127.0.0.1 port 5173 failed: Connection refused
*   Trying [::1]:5173...
* Connected to localhost (::1) port 5173 (#0)
> GET / HTTP/1.1
> Host: localhost:5173
> User-Agent: curl/7.88.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Date: Sun, 22 Oct 2023 08:19:18 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< Content-Length: 2064
< 
<!DOCTYPE html><html lang="en"><head>

Other information

Please let me know if I was unclear or if you need further information to track down the issue.

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@alaendle alaendle added the bug Something isn't working label Oct 22, 2023
@alaendle
Copy link
Contributor Author

alaendle commented Oct 23, 2023

Maybe this is the line (L47) that misses the content-type?

);
try {
const entryServer = (
await viteServer.ssrLoadModule('~analog/entry-server')
)['default'];
const result = await entryServer(req.originalUrl, template);
res.end(result);
} catch (e) {
viteServer && viteServer.ssrFixStacktrace(e as Error);
res.statusCode = 500;

Simple solution might be to simply add something like to line 47:

res.setHeader('Content-Type', 'text/html');

But I'm not expert enough to foresee if this has unwanted side-effects.

@brandonroberts
Copy link
Member

Haven't had any issues so far, but seems like a reasonable fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting PRs bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants