Visitar URL original
Use SiteURL for all calls from the webapp · Issue #70 · mattermost/mattermost-plugin-nps · GitHub
Skip to content

Use SiteURL for all calls from the webapp #70

Open

Description

@mickmister

If the server's SiteURL is configured with a subpath, the webapp's API calls do not work. The task here is to make this plugin's client to prefix its URLs with the SiteURL.

Here's an example of how the SiteURL may be computed:
https://github.com/mattermost/mattermost-plugin-jira/blob/19a9c2442817132b4eee5c77e259b80a40188a6a/webapp/src/selectors/index.js#L13-L26

Activity

  1. mickmister commented on Oct 8, 2020

    @mickmister
    ContributorAuthor

    By default, requests from the frontend to the server are not prefixed with any host. For example, a fetch request like fetch('/api4/users') will be sent to /api4/users. One problem this has is if the server is being hosted on a subpath, or for some reason the server's SiteURL happens to be a different host than the domain that the frontend is connected to, we need to prefix the API calls with the SiteURL.

    An example before the fix:

    fetch('/api4/users');

    But we want

    const siteURL = getSiteURL(state);
    fetch(siteURL + '/api4/users');

    The link in this issue's description is to a different project, just to show how to get the SiteURL. This fix needs to be applied to other plugin projects as well, such as the nps plugin here. The SiteURL is currently not being used in the frontend portion of the nps plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions