Admin not accessible because of auto-minify for Cloudflare

Hello,

I was trying to create a plugin in discourse by following this page: Developing Discourse Plugins - Part 1 - Create a basic plugin and I have uploaded plugins folder on server. After that, I was not able to access admin page on discourse.

When I checked in console of the browser I am seeing below error:
Error: There is no route named admin

I checked in ssh for my user’s role it has admin privileges. I tried deleting plugins folders as well from discourse but I am facing same issue.

Can anyone help me into this issue?

Thanks in advance!

Are you trying to be admin on your development environment or on a production environment?

If it’s production, then you can

cd /var/discourse
./launcher enter app
rake admin:create

For development, you should be able to do a ./bin/rake admin:create from the discourse directory.

Having admin/root privileges on your server OS and in Discourse are two entirely different things.

I tried to change the access using this command ./launcher enter app but it didn’t work for me.
oh, I meant I have admin access in Discourse.

Do you mean you uploaded a plugin directly on your server?

Discourse must compile the plugin’s JavaScript assests firstly. You should upload the plugin to a GitHub repository, edit app.yml to add it, then ./launcher rebuild app

Directly uploading the plugin to the plugins folder without compiling will cause the Discourse frontend to not find the compiled file and cause errors.

Also, if you have cloudflare enabled for your server, remember to turn off auto-minify and delete the cache.

3 Likes

Hi @Lhc_fl

Thank you so much for the help. It worked for me by turning off the auto-minify for Cloudflare.

As I am new to discourse, Hence, I don’t know much how to work with plugin. So, I was trying to add plugin in plugins folder but I tried what you suggested that worked for me by uploading plugin on GitHub and fetch it from GitHub Repository.

May I ask you one more thing, Can you please guide me how can I add custom fields or any additional fields to topic? Actually, I want to create a plugin which enhance topic functionality. I want to add custom fields for topic and store it’s data in database and render it in the topics details page.

Thanks once again!

You should start a new topic for that and the question itself is too broad for a real answer, but you should have a look at Developing Discourse Plugins - Part 1 - Create a basic plugin and the rest. You’ll want to search for stuff about creating topic_custom_fields and adding them to the serializer. See GitHub - discourse/all-the-plugins to get all of the plugins and then you can search those for examples.

You might say more about what you’re doing that requires the custom fields, as there could be some other way to accomplish that task without custom fields and without a plugin.