ironmansoftware / universal-dashboard

Build beautiful websites with PowerShell.

Home Page:https://universaldashboard.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rest API only returns Webpage

antondubek opened this issue · comments

I have been running an API successfully on my machine using the UniversalDashboard.Community powershell module.

I wanted to add a dashboard to monitor some other tasks and operations and so decided to install Powershell Universal via the msi so I could make use of the web interface for management.

Now whenever I start a rest API through powershell, when it is queried it only returns a webpage regardless of endpoint or port.

I have tried to uninstall the Powershell Universal program as well as remove all of the powershell modules and install again however I come up with the same issue. The only way I can get something working is to re-install the msi and do everything through the portal. This however does not allow me to change the port used or run multiple Rest API's.

This is the webpage that is returned using Invoke-RestMethod -Uri http://localhost:8000 with the test powershell script.

<!DOCTYPE html>
<html>
<head>
    <base href="/"/>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>PowerShell Universal Dashboard</title>
    <style>
        .v-wrap{
            height: 100% !important;
            white-space: nowrap !important;
            text-align: center !important;
            display: block !important;
            min-height: auto !important;
            flex-direction: row !important;
        }
        .v-wrap:before{
            content: "";
            display: inline-block;
            vertical-align: middle;
            width: 0;
            /* adjust for white space between pseudo element and next sibling */
            margin-right: -.25em;
            /* stretch line height */
            height: 100vh;
        }
        .v-box{
            display: inline-block;
            vertical-align: middle;
            white-space: normal;
        }
    </style>
<link rel="shortcut icon" href="favicon.ico"></head>
<body>
    <div id="app" class="app"/>
<script type="text/javascript" src="main.a5263d0d4e6d77a7859c.bundle.js"></script><script type="text/javascript" src="vendor.a5263d0d4e6d77a7859c.bundle.js"></script></body>
</html>
Import-Module UniversalDashboard.Community

$Endpoints = @()

$Endpoints += New-UDEndpoint -Url "/healthcheck" -Method "GET" -Endpoint {
    "UP" | ConvertTo-Json
}

$Endpoints += New-UDEndpoint -Url "/time" -Method "GET" -Endpoint {
    Get-Date | ConvertTo-Json
}

Get-UDRestApi | Stop-UDRestApi
Start-UDRestApi -Port 8001 -Endpoint $Endpoints

UniversalDashboard.Community Version 2.9.0
PowershellUniversal Version 1.4.3