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

Gotify component health CORS issue #822

Open
romano opened this issue Nov 7, 2024 · 0 comments
Open

Gotify component health CORS issue #822

romano opened this issue Nov 7, 2024 · 0 comments

Comments

@romano
Copy link

romano commented Nov 7, 2024

Describe the bug
"http://gotify.server.local/health" reports missing CORS header "Access-Control-Allow-Origin". I've managed to allow CORS in Gotify. The service reads message counts but fails to read Gotify's health status.

This bit (lines 54-67) seems to push headers only for messages, but not the health requests. Could be an easy fix but haven't tested it.

   methods: {
    fetchStatus: async function () {
      await this.fetch(`/health`)
        .catch((e) => console.log(e))
        .then((resp) => this.health = resp);
    },
    fetchMessages: async function () {
      const headers = {
        "X-Gotify-Key": this.item.apikey,
      };
      await this.fetch(`/message?limit=100`, { headers })
        .catch((e) => console.log(e))
        .then((resp) => this.messages = resp.messages.length);
    },

As a side note this bit (lines 41-47) returns green health regardless if it achieves connection. Should probably return red by default.

      if (statuses.includes("red")) {
        return "red";
      } else if (statuses.includes("orange")) {
        return "orange";
      }

      return "green";

Expected behavior
No errors

Logs & errors

Browser console output:

TypeError: "focus" is read-only
[contentscript.js:2:347419](moz-extension://31a58c32-a25b-49a4-8767-860809cb7dab/contentscript.js)
Zablokowano żądanie do zasobu innego pochodzenia: zasady „Same Origin Policy” nie pozwalają wczytywać zdalnych zasobów z „http://gotify.server.local/health” (brakujący nagłówek CORS „Access-Control-Allow-Origin”). Kod stanu: 200.

TypeError: this.health is undefined
    status http://homer.server.local/resources/Gotify-BiV2DoYj.js:1
    nl http://homer.server.local/resources/index-DgMKGb2N.js:10
    Ui http://homer.server.local/resources/index-DgMKGb2N.js:10
    runIfDirty http://homer.server.local/resources/index-DgMKGb2N.js:10
    tn http://homer.server.local/resources/index-DgMKGb2N.js:14
    bl http://homer.server.local/resources/index-DgMKGb2N.js:14
    promise callback*gl http://homer.server.local/resources/index-DgMKGb2N.js:14
    br http://homer.server.local/resources/index-DgMKGb2N.js:14
    scheduler http://homer.server.local/resources/index-DgMKGb2N.js:14
    trigger http://homer.server.local/resources/index-DgMKGb2N.js:10
    ur http://homer.server.local/resources/index-DgMKGb2N.js:10
    Tt http://homer.server.local/resources/index-DgMKGb2N.js:10
    set http://homer.server.local/resources/index-DgMKGb2N.js:10
    set http://homer.server.local/resources/index-DgMKGb2N.js:14
    fetchStatus http://homer.server.local/resources/Gotify-BiV2DoYj.js:1
    promise callback*fetchStatus http://homer.server.local/resources/Gotify-BiV2DoYj.js:1
    created http://homer.server.local/resources/Gotify-BiV2DoYj.js:1
    tn http://homer.server.local/resources/index-DgMKGb2N.js:14
    dt http://homer.server.local/resources/index-DgMKGb2N.js:14
    dt http://homer.server.local/resources/index-DgMKGb2N.js:14
    ro http://homer.server.local/resources/index-DgMKGb2N.js:14
    Gf http://homer.server.local/resources/index-DgMKGb2N.js:14
    Gl http://homer.server.local/resources/index-DgMKGb2N.js:14
    Iu http://homer.server.local/resources/index-DgMKGb2N.js:14
    Au http://homer.server.local/resources/index-DgMKGb2N.js:14
    Os http://homer.server.local/resources/index-DgMKGb2N.js:14
    mt http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    L http://homer.server.local/resources/index-DgMKGb2N.js:14
    run http://homer.server.local/resources/index-DgMKGb2N.js:10
    runIfDirty http://homer.server.local/resources/index-DgMKGb2N.js:10
    tn http://homer.server.local/resources/index-DgMKGb2N.js:14
    bl http://homer.server.local/resources/index-DgMKGb2N.js:14
    promise callback*gl http://homer.server.local/resources/index-DgMKGb2N.js:14
    br http://homer.server.local/resources/index-DgMKGb2N.js:14
    scheduler http://homer.server.local/resources/index-DgMKGb2N.js:14
    trigger http://homer.server.local/resources/index-DgMKGb2N.js:10
    ur http://homer.server.local/resources/index-DgMKGb2N.js:10
    notify http://homer.server.local/resources/index-DgMKGb2N.js:10
    trigger http://homer.server.local/resources/index-DgMKGb2N.js:10
    set value http://homer.server.local/resources/index-DgMKGb2N.js:10
    setup http://homer.server.local/resources/index-DgMKGb2N.js:14
    promise callback*setup http://homer.server.local/resources/index-DgMKGb2N.js:14
    tn http://homer.server.local/resources/index-DgMKGb2N.js:14
    Iu http://homer.server.local/resources/index-DgMKGb2N.js:14
    Au http://homer.server.local/resources/index-DgMKGb2N.js:14
    Os http://homer.server.local/resources/index-DgMKGb2N.js:14
    mt http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    L http://homer.server.local/resources/index-DgMKGb2N.js:14
    run http://homer.server.local/resources/index-DgMKGb2N.js:10
    Ae http://homer.server.local/resources/index-DgMKGb2N.js:14
    Os http://homer.server.local/resources/index-DgMKGb2N.js:14
    mt http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    D http://homer.server.local/resources/index-DgMKGb2N.js:14
    ae http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    D http://homer.server.local/resources/index-DgMKGb2N.js:14
    j http://homer.server.local/resources/index-DgMKGb2N.js:14
    R http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    D http://homer.server.local/resources/index-DgMKGb2N.js:14
    ae http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    D http://homer.server.local/resources/index-DgMKGb2N.js:14
    j http://homer.server.local/resources/index-DgMKGb2N.js:14
    R http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    D http://homer.server.local/resources/index-DgMKGb2N.js:14
    j http://homer.server.local/resources/index-DgMKGb2N.js:14
    R http://homer.server.local/resources/index-DgMKGb2N.js:14
[index-DgMKGb2N.js:14:660](http://homer.server.local/resources/index-DgMKGb2N.js)
    Of http://homer.server.local/resources/index-DgMKGb2N.js:14
    sn http://homer.server.local/resources/index-DgMKGb2N.js:14
    tn http://homer.server.local/resources/index-DgMKGb2N.js:14
    bl http://homer.server.local/resources/index-DgMKGb2N.js:14
    (asynchroniczny: promise callback)
    gl http://homer.server.local/resources/index-DgMKGb2N.js:14
    br http://homer.server.local/resources/index-DgMKGb2N.js:14
    scheduler http://homer.server.local/resources/index-DgMKGb2N.js:14
    trigger http://homer.server.local/resources/index-DgMKGb2N.js:10
    ur http://homer.server.local/resources/index-DgMKGb2N.js:10
    Tt http://homer.server.local/resources/index-DgMKGb2N.js:10
    set http://homer.server.local/resources/index-DgMKGb2N.js:10
    set http://homer.server.local/resources/index-DgMKGb2N.js:14
    fetchStatus http://homer.server.local/resources/Gotify-BiV2DoYj.js:1
    (asynchroniczny: promise callback)
    fetchStatus http://homer.server.local/resources/Gotify-BiV2DoYj.js:1
    created http://homer.server.local/resources/Gotify-BiV2DoYj.js:1
    tn http://homer.server.local/resources/index-DgMKGb2N.js:14
    dt http://homer.server.local/resources/index-DgMKGb2N.js:14
    dt http://homer.server.local/resources/index-DgMKGb2N.js:14
    ro http://homer.server.local/resources/index-DgMKGb2N.js:14
    Gf http://homer.server.local/resources/index-DgMKGb2N.js:14
    Gl http://homer.server.local/resources/index-DgMKGb2N.js:14
    Iu http://homer.server.local/resources/index-DgMKGb2N.js:14
    Au http://homer.server.local/resources/index-DgMKGb2N.js:14
    Os http://homer.server.local/resources/index-DgMKGb2N.js:14
    mt http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    L http://homer.server.local/resources/index-DgMKGb2N.js:14
    run http://homer.server.local/resources/index-DgMKGb2N.js:10
    runIfDirty http://homer.server.local/resources/index-DgMKGb2N.js:10
    tn http://homer.server.local/resources/index-DgMKGb2N.js:14
    bl http://homer.server.local/resources/index-DgMKGb2N.js:14
    (asynchroniczny: promise callback)
    gl http://homer.server.local/resources/index-DgMKGb2N.js:14
    br http://homer.server.local/resources/index-DgMKGb2N.js:14
    scheduler http://homer.server.local/resources/index-DgMKGb2N.js:14
    trigger http://homer.server.local/resources/index-DgMKGb2N.js:10
    ur http://homer.server.local/resources/index-DgMKGb2N.js:10
    notify http://homer.server.local/resources/index-DgMKGb2N.js:10
    trigger http://homer.server.local/resources/index-DgMKGb2N.js:10
    set value http://homer.server.local/resources/index-DgMKGb2N.js:10
    setup http://homer.server.local/resources/index-DgMKGb2N.js:14
    (asynchroniczny: promise callback)
    setup http://homer.server.local/resources/index-DgMKGb2N.js:14
    tn http://homer.server.local/resources/index-DgMKGb2N.js:14
    Iu http://homer.server.local/resources/index-DgMKGb2N.js:14
    Au http://homer.server.local/resources/index-DgMKGb2N.js:14
    Os http://homer.server.local/resources/index-DgMKGb2N.js:14
    mt http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    L http://homer.server.local/resources/index-DgMKGb2N.js:14
    run http://homer.server.local/resources/index-DgMKGb2N.js:10
    Ae http://homer.server.local/resources/index-DgMKGb2N.js:14
    Os http://homer.server.local/resources/index-DgMKGb2N.js:14
    mt http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    D http://homer.server.local/resources/index-DgMKGb2N.js:14
    ae http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    D http://homer.server.local/resources/index-DgMKGb2N.js:14
    j http://homer.server.local/resources/index-DgMKGb2N.js:14
    R http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    D http://homer.server.local/resources/index-DgMKGb2N.js:14
    ae http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    D http://homer.server.local/resources/index-DgMKGb2N.js:14
    j http://homer.server.local/resources/index-DgMKGb2N.js:14
    R http://homer.server.local/resources/index-DgMKGb2N.js:14
    d http://homer.server.local/resources/index-DgMKGb2N.js:14
    D http://homer.server.local/resources/index-DgMKGb2N.js:14
    j http://homer.server.local/resources/index-DgMKGb2N.js:14
    R http://homer.server.local/resources/index-DgMKGb2N.js:14

Screenshots
n/a

Configuration
n/a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant