IDX Preview Not Working for Any Web Server I create

I have a Python/Flask application that I am trying to get a preview for the web page being developed.

I have setup dev.nix to point to the proper port that is being opened, the output is confirming that the app is starting properly. However, the preview pane is just consistently refreshing and is completely blank. The code works great locally and I can see my web page just fine with the same exact code.

I’m not sure how to diagnose this issue and determine why the preview pane isn’t working. The address bar doesn’t really seem to do anything either. If I try to go to a page that doesn’t exist on the server, I don’t get the expected 404 error either.

Any ideas? TIA

1 Like

Wow, I just figured it out.

I changed my “command” in the dev.nix file to “python -m flask --app app run -p $PORT --debug” (Previously was “python app.js”). Not sure what the difference is, but that is what it is.

I had imported a previous project from GitHub and obviously wasn’t configured for Nix, so I just created a new Flask project through IDX and started toying around with the differences in the dev.nix file.

3 Likes

glad you got it figured out! Yeah, we have a predefined port for previews that web servers need to listen on — that’s why $PORT was probably needed.

1 Like

I had defined $PORT under the dev.nix file in the env section. Does that allow you to change the port? Or should I just leave that alone?