Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85827946
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/services/hosted/hosted.js b/src/services/hosted/hosted.js
index 3a4e744b39..667aef36a9 100644
--- a/src/services/hosted/hosted.js
+++ b/src/services/hosted/hosted.js
@@ -1,58 +1,57 @@
// Hosted mode: this frontend served from its own domain, logging into an
// instance the user picks. The site turns it on in its static/config.json
// ("hosted": true); an instance serving the frontend itself never does.
const INSTANCE_KEY = 'pleroma-fe-hosted-instance'
-export const isHosted = (staticConfig) =>
- staticConfig?.hosted === true || window.___pleromafe_hosted_mode
+export const isHosted = (staticConfig) => staticConfig?.hosted === true || Boolean(window.___pleromafe_hosted_mode)
// "pleroma.example", "@me@pleroma.example" or a URL on it -> its origin
export const instanceOrigin = (input) => {
const text = (input ?? '').trim().replace(/^@?[^@\s/]+@/, '')
if (!text) return null
try {
const url = new URL(/^https?:\/\//i.test(text) ? text : `https://${text}`)
const local = url.hostname === 'localhost'
if (!url.hostname.includes('.') && !local) return null
// the login token never goes over plain http to a real server
if (!local) url.protocol = 'https:'
return url.origin
} catch {
return null
}
}
export const chosenInstance = () => localStorage.getItem(INSTANCE_KEY)
export const chooseInstance = (origin) =>
localStorage.setItem(INSTANCE_KEY, origin)
export const forgetInstance = () => localStorage.removeItem(INSTANCE_KEY)
// an instance answers /api/v1/instance with JSON, and lets this site ask
export const checkInstance = async (origin, fetch = window.fetch) => {
try {
const res = await fetch(`${origin}/api/v1/instance`)
if (!res.ok) return false
const data = await res.json()
return typeof data?.uri === 'string'
} catch {
return false
}
}
// The instance's frontend configuration, for use on this site: its paths
// (logo, background, default avatar…) point at the instance, app routes
// stay routes, and login goes through the instance's own login page.
export const instanceConfig = (config, resolve) => ({
...Object.fromEntries(
Object.entries(config ?? {}).map(([key, value]) => [
key,
typeof value === 'string' &&
value.startsWith('/') &&
!key.startsWith('redirect')
? resolve(value)
: value,
]),
),
loginMethod: 'token',
})
diff --git a/tools/spa.nginx.conf b/tools/spa.nginx.conf
index 71778edd90..59c085e266 100644
--- a/tools/spa.nginx.conf
+++ b/tools/spa.nginx.conf
@@ -1,23 +1,23 @@
location ^~ /api {
return 404;
}
location ^~ /auth {
return 404;
}
location ^~ /nodeinfo {
return 404;
}
location ^~ /instance {
return 404;
}
-location ^~ /oauth {
+location ^~ /oauth/ {
return 404;
}
location / {
try_files $uri $uri/ /index.html;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Oct 31, 12:37 AM (16 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1800820
Default Alt Text
(2 KB)
Attached To
Mode
rPUFE pleroma-fe-upstream
Attached
Detach File
Event Timeline