Skip to content

500 on request #223

@timowevel1

Description

@timowevel1

Hello,

I think its rather an error with the way I use it, but I cannot figure it out.

With postman I tried to test with

GET https://domain/index.php/apps/webapppassword/api/v1/shares?path=/Assessments/Max%20Mustermann/11.09.2024/8ed25dc5-d4f6-4a3f-9e51-05024ccb38e3.mp4

Authorization with Basic

Nextcloud 28.0.5

Header OCS-APIRequest to true

image

As return in the body it returns me the HTML code of nextcloud
`

<title> Nextcloud </title>
This application requires JavaScript for correct operation. Please enable JavaScript and reload the page.

Nextcloud

Internal Server Error

The server was unable to complete your request.

If this happens again, please send the technical details below to the server administrator.

More details can be found in the server log.

                <h3>Technical details</h3>
                <ul>
                    <li>Remote Address: 91.0.47.62</li>
                    <li>Request ID: XpJQ1rBdGwrb9ek1etW4</li>
                </ul>

            </div>
        </main>
    </div>
</div>
<footer class="guest-box ">
    <p class="info">
        <a href="https://nextcloud.com" target="_blank" rel="noreferrer noopener" class="entity-name">Nextcloud</a>
        – a safe home for all your data
    </p>
</footer>
`

When I embed that into my application it returns me a cors error

Access to fetch at 'https://domain/index.php/apps/webapppassword/api/v1/shares?path=/Assessments/Max%20Mustermann/11.09.2024/8ed25dc5-d4f6-4a3f-9e51-05024ccb38e3.mp4' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Code:

`const fetchVideoShareLink = async (path) => {
// Extract the part starting from "/Assessments"
const cleanPath = path.substring(path.indexOf("/Assessments"));
console.log(cleanPath)

const response = await fetch(`https://xxx/index.php/apps/webapppassword/api/v1/shares?path=${cleanPath}`, {
    method: 'GET',
    headers: {
        'Authorization': `Basic ${btoa('username:password')}`, // Replace 'username' and 'password' with actual credentials
        'OCS-APIRequest': 'true',
    },
});

console.log(response)

if (response.ok) {
    const data = await response.json();
    if (data.ocs && data.ocs.data && data.ocs.data.length > 0) {
        return data.ocs.data[0].url; // Return the share URL
    } else {
        throw new Error('No share link found.');
    }
} else {
    throw new Error('Error fetching share link.');
}

};`

Any idea what I am doing wrong?

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