Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The following error was encountered: Unexpected token '', "{ "na"... is not valid JSON #937

Open
mla157 opened this issue Mar 4, 2025 · 1 comment

Comments

@mla157
Copy link

mla157 commented Mar 4, 2025

SWA Version: 2.0.4

Describe the bug
When I run swa deploy or swa I get a JSON validation error, even my JSON's config files for the staticwebapp-config.json are all valid json.
With this state I can not deploy a SWA with a config.

To Reproduce

  1. Place a json with the name "staticwebapp.config.json" in our "app" folder with the content {}
  2. Run swa deploy

The following error occurs on my end:

WARNING: Failed to read staticwebapp.config.json configuration from:
C:\folder1\folder2\folder3\client\staticwebapp.config.json

✖ The following error was encountered: Unexpected token '', "{}" is not valid JSON
Please fix the above error and try again to load and use the configuration.
Read more: https://aka.ms/swa/config-schema

At this state the staticwebapp.config.json only contains {}
But I tried configurations like the this one, and they not working too.

{
    "navigationFallback": {
        "rewrite": "/index.html"
    }
}

Error Message:

✖ The following error was encountered: Unexpected token '', "{
"na"... is not valid JSON

Expected behavior
Deployment Working

Desktop (please complete the following information):

  • OS: Windows
  • Version PS7

Additional context
Add any other context about the problem here.

@mla157
Copy link
Author

mla157 commented Mar 4, 2025

The problem is the following:
The JSON parser only accepts hardcoded UTF-8 and not UTF-8 with BOM for example.
I think It is needed, that the JSON parsers tries multiple encodings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant