me-no-dev / ESPAsyncWebServer

Async Web Server for ESP8266 and ESP32
3.67k stars 1.21k forks source link

Serving SPIFFS from a subdirectory raises 500 status code on some files #1400

Closed Skyslycer closed 4 months ago

Skyslycer commented 4 months ago

I'm currently trying to serve a website in a subdirectory of SPIFFS. I can serve the index.html just fine, but files in a subdirectory of that directory like assets/index-GFgXtGjb.js just return a 500 Server Error.

It works when the files to serve are in the root of SPIFFS, but not like this. image image

Code:

#include <Arduino.h>
#include "SPIFFS.h"
#include "ESPAsyncWebServer.h"

AsyncWebServer server(80);

void setup() {
    Serial.begin(115200);
    SPIFFS.begin();
    WiFi.mode(WIFI_STA);
    WiFi.begin("x", "x");
    while(WiFi.status() != WL_CONNECTED){
        Serial.print(WiFi.status());
        delay(100);
    }
    Serial.println();
    Serial.println(WiFi.localIP());
    server.serveStatic("/", SPIFFS, "/website").setDefaultFile("index.html");
    server.begin();
}

void loop() {
}

Please fix this soon or at least tell me how to fix it so I can make a pull request. Thank you in advance!

Skyslycer commented 4 months ago

Solved using LittleFS as SPIFFS is a flat only file system (without real directories).