I’m building a website using strapi, with the help of this (outdated but still helpful) tutorial.
When I run hugo server
, I get this error:
ERROR 2023/08/20 02:15:10 Failed to get JSON resource "http://127.0.0.1:1337/api/about?locale=en": Get "http://127.0.0.1:1337/api/about?locale=en": dial tcp 127.0.0.1:1337: connect: connection refused
If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
ignoreErrors = ["error-remote-getjson"]
(It repeats six times, which is the number of pages I have).
Strangely, when I run it a second time (without restarting strapi), I get a different error, this time only twice, then an infinite recursion error after a delay:
Start building sites …
hugo v0.111.3+extended linux/amd64 BuildDate=2023-03-16T08:41:31Z VendorInfo=debian:0.111.3-1
ERROR 2023/08/20 02:15:18 Failed to get JSON resource "http://127.0.0.1:1337/api/about?locale=en": Get "http://127.0.0.1:1337/api/about?locale=en": read tcp 127.0.0.1:39144->127.0.0.1:1337: read: connection reset by peer
If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
ignoreErrors = ["error-remote-getjson"]
ERROR 2023/08/20 02:15:18 Failed to get JSON resource "http://127.0.0.1:1337/api/home?locale=en": Get "http://127.0.0.1:1337/api/home?locale=en": read tcp 127.0.0.1:39170->127.0.0.1:1337: read: connection reset by peer
If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
ignoreErrors = ["error-remote-getjson"]
Error: Error building site: failed to render pages: render of "page" failed: "/home/cyrille/Dev/Perso/Web/strapi-hugo-blog/docs-app/themes/book/layouts/_default/baseof.html:24:9": execute of template failed: template: _default/single.html:24:9: executing "_default/single.html" at <partial "docs/inject/content-after" .>: error calling partial: partial "docs/inject/content-after" timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the 'timeout' config setting.
Built in 30065 ms
In config.toml
, I have tried to set my strapi server URL to http://127.0.0.1:1337/api
and http://localhost:1337/api
, I get the same error.
When I open for example http://127.0.0.1:1337/api/about?locale=en in a browser, my JSON data appears and I can see the request in the console where Strapi is running. I see nothing when trying to start the Hugo server.
Here is the code of the partial that fetches the data:
<!-- Partial to fetch content from Strapi. -->
{{ $endpoint := $.Param "endpoint" }}
{{ $data := dict "title" "" "content" "" }}
{{ if and $endpoint .Site.Params.StrapiServerURL }}
{{ $contentURL := printf "%s%s" .Site.Params.StrapiServerURL $endpoint }}
{{ $data = getJSON $contentURL }}
{{ end }}
{{ return $data }}