The origin hubs repo is always updating and we are running on different server so it comes with different kind of error.
Sometimes the error I face doesn't necessarily mean you also face it.
Before we solve this postgrest issue read why this become issue
scope "/api/postgrest" do
pipe_through([:secure_headers, :auth_required, :admin_required, :proxy_api])
forward("/", RetWeb.Plugs.PostgrestProxy)
end
Thanks to the contributor that give me a clue about the port 3000
its a PostgREST
Thanks to daniel, Give me info about Running PostgREST locally
If you want to see the implementation of postgrest on this hubs see:
Run postgrest with hubs on local
Run hubs admin as a static file so it can access postgress on local
Then...
and make condition like this picture bellow
Edit Api.js to bypass thumbnail resize service.
Second way:
In reticulum config/dev.exs
append https://nearspark-dev.reticulum.io
to asset_hosts
if you won't self-host nearspark, that for csp rules setting.
asset_hosts =
"https://localhost:4000 https://localhost:8080 " <>
"https://#{host}:4000 https://#{host}:8080 https://#{host}:3000 https://#{host}:8989 https://#{host}:9090 https://#{cors_proxy_host}:4000 " <>
"https://assets-prod.reticulum.io https://asset-bundles-dev.reticulum.io https://asset-bundles-prod.reticulum.io https://hubs.local:5000 " <>
"https://nearspark-dev.reticulum.io"
or you can directly edit lib/ret_web/plugs/add_csp.ex
.
Self-hosted Nearspark(thumbnail server):
Nearspark resizes preview images to 200x200 thumbnails for some media source like Sketchfab.
The original NearSpark repository (https://github.com/MozillaReality/nearspark) is not compatible with Node.js version 16 (node-gyp problem) and has a bug related to base64 URL decode. To address these issues, Use a fork of the repository and added support for the certs/
directory for HTTPS settings. You can find fork at https://github.com/XuHaoJun/nearspark
Clone, copy certs/
, install dependencies, and start.
git clone https://github.com/XuHaoJun/nearspark.git
cp hubs/certs nearspark
cd nearspark
npm ci
node app.js
set environment variable THUMBNAIL_SERVER="localhost:5000"
in Spoke.
Open up the nginx configuration file
sudo nano /etc/nginx/nginx.conf
add this client_max_body_size
to the http section
http {
# other line...
client_max_body_size 100M;
}
Then restart nginx
sudo systemctl restart nginx
for more detail see this article
To obtain a Sketchfab API key, go to (https://sketchfab.com/settings/password). Once you have obtained the API key,
you can set it in the config/dev.exs
file of Reticulum as shown in the following:
config :ret, Ret.MediaResolver,
giphy_api_key: nil,
deviantart_client_id: nil,
deviantart_client_secret: nil,
imgur_mashape_api_key: nil,
imgur_client_id: nil,
youtube_api_key: nil,
sketchfab_api_key: "YOUR_API_KEY_HERE",
ytdl_host: nil,
photomnemonic_endpoint: "https://uvnsm9nzhe.execute-api.us-west-1.amazonaws.com/public"
If thumbnails not work, go to Spoke Assets Thumbnail not Showing on Production section.
Sketchfab tab should work.
then i got that error when trying to run Spoke and hubs admin.
just remove process.env.HOST_IP ||
like picture above.
and leave "0.0.0.0"
thanks to this
Change the prod command in package.json
it because MEDIASOUP_LISTEN_IP
. set value with 0.0.0.0
MEDIASOUP_LISTEN_IP=0.0.0.0 MEDIASOUP_ANNOUNCED_IP=123.xxx.xxx.xxx HTTPS_CERT_FULLCHAIN=/etc/letsencrypt/live/example.com/fullchain.pem HTTPS_CERT_PRIVKEY=/etc/letsencrypt/live/example.com/privkey.pem DOMAIN=example.com node index.js
I modify reticulum on lib/ret_web/controllers/api/v1/media_controller.ex
become this code
# This is an error response that we have cached ourselves
defp render_resolved_media_or_error(conn, {_status, :error}) do
# DON'T THROW ERROR
url = conn.params["media"]["url"]
content_type = MIME.from_path(url)
resolved_media = URI.parse(url) |> Ret.MediaResolver.resolved(%{expected_content_type: content_type})
render_resolved_media(conn, resolved_media)
# send_resp(conn, 500, "An error occured during media resolution")
end
I modify reticulum on /lib/ret/media_resolver.ex
Become
def resolve(%MediaResolverQuery{} = query, root_host) do
# If we fall through all the known hosts above, we must validate the resolved ip for this host
# to ensure that it is allowed.
resolved_ip = HttpUtils.resolve_ip(query.url.host)
case resolved_ip do
nil ->
:error
resolved_ip ->
if HttpUtils.internal_ip?(resolved_ip) do
resolvedMedia = resolve_with_content_type(query)
{:commit, resolvedMedia}
# :forbidden
else
resolve_with_ytdl(query, root_host, query |> ytdl_format(root_host))
end
end
end
And add this code bellow it
def resolve_with_content_type(%MediaResolverQuery{url: %URI{} = uri}) do
content_type = MIME.from_path(uri.path)
uri |> resolved(%{expected_content_type: content_type})
end
When running reticulum locally got this error.
[error] Postgrex.Protocol (#PID<0.651.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
i install postgres with brew, so we need to list all the brew services.
brew services list
then see
For Apple Silicone Macs use rm /opt/homebrew/var/postgres/postmaster.pid
as the brew folder is by default in a /opt/homebrew
instead of /usr/local
then restart the postgres services with
brew services restart postgresql@14
How to Maintenance Server (Backup, etc)