Question

Accessing file with POST on static website app returns 405 Method not allowed over https

I did deploy of VueJS with Vite app as a static Website. In project I have folder api-mockups with json files. When I access those files over https I get 405 Method not allowed. But when I hit those endpoints from postman as http, it works fine. How to configure server to enable https access as well?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

This comment has been deleted

    Bobby Iliev
    Site Moderator
    Site Moderator badge
    February 13, 2024

    Hey,

    Since you’re dealing with a static site deployment, it’s important to note that static site servers are typically configured to serve files via GET requests and may not support POST requests for accessing static files like your JSON mockups.

    This would explain why you’re seeing a 405 error; the server does not allow POST methods on the requested resource.

    Here are some approaches to resolve this issue:

    1. Use GET Requests for Static Files: If your application is attempting to access static JSON files using POST requests, consider changing these requests to GET. Since these files are static, using GET requests is more semantically correct and should be supported by the server.

    2. Server Configuration: On the DigitalOcean App Platform for static sites, you have limited control over the web server configuration since it’s a Platform as a Service offering. This means you cannot directly change the server settings to allow POST requests for static files. If this is a requirement for you, you might want to consider using a Droplet instead where you have full root access and you can make any configuration changes that you need.

    3. API Service: If your application logic requires POST requests (for example, if you’re sending data to the server that determines the response), consider deploying a separate API service that can handle these requests. You can deploy a small server-side application (using Express.js with Node.js, Flask with Python, etc.) alongside your static site on the DigitalOcean App Platform. This API service can then respond to POST requests and serve the necessary JSON data.

    Let me know how it goes!

    Best,

    Bobby

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Become a contributor for community

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    DigitalOcean Documentation

    Full documentation for every DigitalOcean product.

    Resources for startups and SMBs

    The Wave has everything you need to know about building a business, from raising funding to marketing your product.

    Get our newsletter

    Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

    New accounts only. By submitting your email you agree to our Privacy Policy

    The developer cloud

    Scale up as you grow — whether you're running one virtual machine or ten thousand.

    Get started for free

    Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

    *This promotional offer applies to new accounts only.